Book a Demo

Author Topic: HasTag anomalies  (Read 69968 times)

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: HasTag anomalies
« Reply #15 on: May 12, 2016, 02:06:08 pm »
In terms of the practical purpose of this thread as a discussion of if EA should be changed.

Both forms of HasTag behave as if they are evaluating based on a single call to get the value. As a result:

HasTag(tagname) gives a result that doesn't match the function name when an empty tag is present
HasTag(tagname, tagvalue) gives a result that doesn't match the function name when no tag is present and checking for an empty value

Unfortunately, changing the behavior of either of these cases would almost certainly break existing shape scripts out there in user land. I'm not willing to do that. The documentation will have to be updated to clarify the behavior and there will have to a be a separate solution to your requirement of distinguishing between an empty value and a missing tag.

Additionally, don't expect to see any change to purge tagged values that are empty. There are too many users that depend on the way it currently works. Not just in the UI, but in documentation, API and export functions.


For the conceptual topic that is diverging further and further from being useful...

Whoops!  As per Helsinki, I should have defined my terms:
«Empty», «Missing», «Not present»   There should be a value, but none was provided
«Unknown»   There is a value but we don't know what it is
«None», «No one», «Nothing»      There is NO Value
«Not applicable»   NO value can be applied

are just some of the standard extrinsic definitions I use.

Useful categories in theory. Like you, I could add additional categories. Where I disagree with you is the inclusion of «Empty» into no value was provided. I would define a string as a sequence of zero or more characters. Similar to sets, I consider empty to be a useful value in its own right. Empty may not be permitted in your model, but the appropriate place to specify that is in a constraint, not the definition of what a (string) value is. As an example, I define a function that removes all instances of a single character from a string. Logically it has to result in a string. If the string only contained the specified character there's certainly a value there. As far as I'm concerned it's still a string.


How does that impact EA?

For string tagged values, the only category that can be stored against a tag in EA is the empty string. As I said, in my opinion this is distinct from a null value and still useful. The only way to represent a none or missing value is to delete the tag. In addition to shape scripts, reporting, code generation and csv exports that request the value of a tag by name will be unable to distinguish between these two states. For that reason I would no recommend placing too much significance on the that difference.

For other tagged values (eg. Boolean, enumeration, Dates) the situation is slightly different because unless otherwise specified the default will still be represented by an empty string. For those types there is a missing or none state, but often the UI doesn't allow you to go back to it after it gets a value.

Glassboy

  • EA Practitioner
  • ***
  • Posts: 1367
  • Karma: +112/-75
    • View Profile
Re: HasTag anomalies
« Reply #16 on: May 12, 2016, 02:33:58 pm »
In terms of the practical purpose of this thread as a discussion of if EA should be changed.

Both forms of HasTag behave as if they are evaluating based on a single call to get the value. As a result:

HasTag(tagname) gives a result that doesn't match the function name when an empty tag is present
HasTag(tagname, tagvalue) gives a result that doesn't match the function name when no tag is present and checking for an empty value

Unfortunately, changing the behavior of either of these cases would almost certainly break existing shape scripts out there in user land. I'm not willing to do that. The documentation will have to be updated to clarify the behavior and there will have to a be a separate solution to your requirement of distinguishing between an empty value and a missing tag.

You somewhat seem to address your own point.  Introduce a new properly named function call that returns results for all possible conditions.  Deprecate the old function calls.

skiwi

  • EA Expert
  • ****
  • Posts: 2081
  • Karma: +46/-82
    • View Profile
Re: HasTag anomalies
« Reply #17 on: May 16, 2016, 11:32:41 am »
You somewhat seem to address your own point.  Introduce a new properly named function call that returns results for all possible conditions.  Deprecate the old function calls.
+1, and noting the previous link to the billion$ mistake, don't introduce any new 'null' values.
Orthogonality rules
Position and Team disestablished, thanks austerity.
Now itinerant.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: HasTag anomalies
« Reply #18 on: May 16, 2016, 11:56:52 am »
Actually, I intentionally didn't describe what any alternate solution might be.

For the record:
  • The referenced article about null never implies that null isn't necessary.
  • It just proposes wrapping it in a type called Optional.
  • From my point of view a C/C++ pointer is effectively that construct.
  • All Java objects are optional (but the primitives aren't).
  • Null doesn't have to be considered breaking a type system because it's an overloaded constant.
  • The "double null" described for javascript undefined constant seems to be a total misconception. I'd prefer that over the default C/C++ behavior of there's no way to check for that situation.
  • Apart from that, it's just about rigorous programming practices. (Which avoiding the presence of null in a language would force)
« Last Edit: May 16, 2016, 12:04:05 pm by Simon M »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: HasTag anomalies
« Reply #19 on: May 16, 2016, 04:36:58 pm »
The HasTag(tagname) query method ONLY evaluates to true if the tag has a value, not if it just exists.  Which I submit is contrary to the documentation:
"Evaluates to true if the associated element has a tag with the name tagname."

Perversely, HasTag(tagname,””) will  fire if the tag has an empty (null) value or EVEN if the tag does not exist, which again, I submit is contrary to the documentation:
"If the second parameter tagvalue is provided, the tag tagname must be present, and the value of the tag has to be equal to tagvalue for the method to evaluate to true."

Reported,
Paolo
After all that, are we agreed that the above implementation is WRONG and needs to be fixed...

HasTag (from its name) is a function that deals with Tags, with or without an applied value.  So HasTag  cannot return true (in either form) if the tag doesn't exist.

I'll leave it at that. 

Without some sort of extrinsic(s) or pattern matching syntax, I don't think one can check for:
Null/Empty only tag; any non-empty value; specific non-empty value(s).  With the currently available function syntax.
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: HasTag anomalies
« Reply #20 on: May 17, 2016, 08:46:07 am »
After all that, are we agreed that the above implementation is WRONG and needs to be fixed...

HasTag (from its name) is a function that deals with Tags, with or without an applied value.  So HasTag  cannot return true (in either form) if the tag doesn't exist.
You seem very selective on what you read. The conclusion was that changing either HasTag function could negatively impact existing scripts and therefore a new function would be required to detect the situations you described.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: HasTag anomalies
« Reply #21 on: May 17, 2016, 09:37:43 am »
After all that, are we agreed that the above implementation is WRONG and needs to be fixed...

HasTag (from its name) is a function that deals with Tags, with or without an applied value.  So HasTag  cannot return true (in either form) if the tag doesn't exist.
You seem very selective on what you read. The conclusion was that changing either HasTag function could negatively impact existing scripts and therefore a new function would be required to detect the situations you described.
How can fixing HasTag(tagname, value) to NOT return true if the tag doesn't exist (not the value, the tag) adversely affect existing shapescripts?  It's a bug, !

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Glassboy

  • EA Practitioner
  • ***
  • Posts: 1367
  • Karma: +112/-75
    • View Profile
Re: HasTag anomalies
« Reply #22 on: May 17, 2016, 10:25:16 am »
It's a bug, !

I feel the forum needs some form of voting functionality so we can sweepstakes on what decade your pop culture references are from :-)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: HasTag anomalies
« Reply #23 on: May 17, 2016, 10:52:11 am »
It's a bug, !

I feel the forum needs some form of voting functionality so we can sweepstakes on what decade your pop culture references are from :-)
Just reply with your guesses...  ;D  The first right answer...













                                     is the first right answer.  8) 


It's not a sweepstakes, it's a quiz... :P

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

skiwi

  • EA Expert
  • ****
  • Posts: 2081
  • Karma: +46/-82
    • View Profile
Re: HasTag anomalies
« Reply #24 on: May 17, 2016, 11:23:17 am »
I would have thought its a bug 'Grace' to be closer to the etymology entomology.


Of course this could be a West Island colloquiality (see http://www.kevinservices.com.au/bed-bug-treatments/)
« Last Edit: May 17, 2016, 11:26:05 am by skiwi »
Orthogonality rules
Position and Team disestablished, thanks austerity.
Now itinerant.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: HasTag anomalies
« Reply #25 on: May 17, 2016, 11:27:58 am »
With the current behavior of HasTag, a technology developer can use either version of the function to determine if it should use that value or another value.

Code: [Select]
shape main
{
  rectangle(0,0,100,100);
  if(HasTag("NameOverride"))
  {
    println("#TAG:NameOverride#");
  }
  else
  {
    println("#name#");
  }
  if(HasTag("NameOverride", ""))
  {
    println("#name#");
  }
  else
  {
    println("#TAG:NameOverride#");
  }
}

I consider this usage in user profiles not only possible, but likely. Therefore, the behavior of those functions can't be changed.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: HasTag anomalies
« Reply #26 on: May 17, 2016, 01:03:54 pm »
With the current behavior of HasTag, a technology developer can use either version of the function to determine if it should use that value or another value.

Code: [Select]
shape main
{
  rectangle(0,0,100,100);
  if(HasTag("NameOverride"))
  {
    println("#TAG:NameOverride#");
  }
  else
  {
    println("#name#");
  }
  if(HasTag("NameOverride", ""))
  {
    println("#name#");
  }
  else
  {
    println("#TAG:NameOverride#");
  }
}

I consider this usage in user profiles not only possible, but likely. Therefore, the behavior of those functions can't be changed.
Not sure what you are trying to achieve  with this snippet.  The behaviour with an empty tag or no tag is identical.  Consequently, I can't tell if the tag (again, not the value) exists or not.

I guess users don't need to know if the tag exists or not.  If they do, then I guess they use the TagExists(tagname) function.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: HasTag anomalies
« Reply #27 on: May 17, 2016, 01:35:44 pm »
My point is that existing shape scripts that we don't have control of are likely to be using HasTag and don't care about which of those scenarios it is.

To prevent changing the behavior of existing scripts we need to preserve the current behavior for HasTag, and introduce something new the check if no matching tag exists.

Glassboy

  • EA Practitioner
  • ***
  • Posts: 1367
  • Karma: +112/-75
    • View Profile
Re: HasTag anomalies
« Reply #28 on: May 17, 2016, 01:42:45 pm »
I would have thought its a bug 'Grace' to be closer to the etymology entomology.

That's what I was thinking, but the nifty pun hadn't occurred to me :-)  Possibly there's a Norman Gunston boxed set we could get shipped over to help with these references. 

Glassboy

  • EA Practitioner
  • ***
  • Posts: 1367
  • Karma: +112/-75
    • View Profile
Re: HasTag anomalies
« Reply #29 on: May 17, 2016, 01:45:31 pm »
My point is that existing shape scripts that we don't have control of are likely to be using HasTag and don't care about which of those scenarios it is.

To prevent changing the behavior of existing scripts we need to preserve the current behavior for HasTag, and introduce something new the check if no matching tag exists.

Yes, which the whole point of deprecation.