-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative comparison operators #2
Comments
Thanks, Grimble! Expanding these selection modes will improve usage. I'd support... |
The 'mem' example perfectly justifies the request for enhancement. I would not agree with returning an error with non-numeric operations. Letters or even strings are also comparable: a<b<c<d<...<z Good job, man! |
Including string comparisons amplifies the complexity of the parser as well as the definition of the logic (ie, user confusion.) Consider "05>5". Is that a numeric comparison? Is "greater than" based on string length, or sort order? What about "a>10"? Since one operand is non-numeric does that force a string comparison? Or do strings compared to numbers evaluate as zero? And "THIS>this"? Does case matter? Is THIS greater than this because it sorts out first in an ASCII collation? What about in other collations? What about symbols? Unicode characters? There are definite rules for numeric comparisons, but strings are a madhouse. This is why I proposed, in keeping with genders+nodeattr being a simple query system, for non-numeric operands to cause a short-circuit evaluation and return a null result. |
Currently there are three selection modes - name exists, name=value, or the complement thereof. I propose adding relative comparisons of the following types:
These should be constrained to either integer or float values. For example:
I cannot at the moment think of a float value. I think automatic casting is probably overkill and (personally) would think integer is sufficient.
In the event a non-integer value is supplied, there are a few possibilities:
I prefer the second option, since a non-integer string is an error.
Note that, if the NOT operator previous suggested is implemented, then you could get by with implementing only < and >.
That said, I think <= and >= are a bit more mainstream and definitely easier to read and understand.
The text was updated successfully, but these errors were encountered: