-
Notifications
You must be signed in to change notification settings - Fork 911
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
Disabling string compairson for operators: < <= > >= #109
Conversation
Non-numeric operands causes a 'Type mismatch.' error. Reason: Superseded by StrCompare which doesn't cause a loss of information. Simplifies the behaviour of the operators.
From #107
So do we agree that StrCompare </>/<=/>= 0 is not intuitive and must be learned through frequent repetition? I think your implication is that you would be using it more often, and therefore would learn to recognize it more readily. I do not think it can be trivialized in that way. I do not believe I would be using StrCompare often for any kind of comparison, and by extension I do not believe the average user would become accustomed to this kind of comparison. Even if they did, there would be a period for each new user where it is hard to understand. That aside, I do not believe that your arguments for removing the operators thus far are sufficient. |
Hello 👋 . I agree that
No, I would use That aside, the point isn't that The only reasonable cases for these operators, imo, are to only allow,
together with,
or only,
Compare to the current state which is,
together with,
plus a) and b), this is by far less intuitive and hard to keep track of than the use of I'm fine with a) and b) instead of c) (this PR), but as I have understood, you value the ability to use numeric strings as numbers, hence I picked c), which is also consistent with math operators and functions. The I'm not passionate about having it exactly this way, but just that a change is needed. I would be interested in seeing any other suggestions, from anyone. A few more comments on #107
With the function, reversing the result is as easy as multiply by
Even if you continue to support string compairson with operators, the better option for the above is, Cheers ☕️ . |
It is more verbose and less intuitive, and requires referring to the documentation more often. In other words, it is more difficult to write, read and use. "Difficult" is subjective, and there are degrees.
That reminds me I have utilized this. In a loop finding the smallest number,
I think you exaggerate the issue, and I disagree with this proposed solution. (But perhaps if we take this to the forum and a majority of other vocal users offer opinions aligned with yours, it will wear down my resistance to the idea.) I chose the current behaviour because I felt it was intuitive at the time. I would not expect to have to refer to the documentation. Aside from the change regarding two numeric strings (which I've already explained and admitted might be a bad idea), v1 has had this behaviour for a long time, and I do not see it as a significant source of problems.
I don't understand. If you're not already storing the result, there is no need to store it to reverse it. I was talking about (in what you quoted) simple comparison of two values, giving a boolean result. Reversing the result is even easier than multiplying by -1. If you are multiplying by -1, it is because you have a three-way result; for that case, it was already clear that using something which gives a three-way result is better than combining multiple operators to get it. But even so, reversing the result means exactly the same amount of additional code either way.
Hypothetically, this expression would always be true (and therefore pointless), since This option implies A_AhkVersion is one of:
If A_AhkVersion is not a string, it must be implicitly convertible to string. That isn't yet possible for objects. This isn't necessary in the first place, because string comparisons work for A_AhkVersion, and I take care to preserve this. For instance, I chose Also, We might even avoid the issue by using a floating-point version number (just major and minor), but that can't take into account alpha/test versions. |
The fact that "" compares to numbers successfully does not seem like an advantage. How many times would you actually want to compare the number to a string and how many times did that happen just because you had a bug. For me the latter is far greater and I can even accurately tell the amount of times I did the former: once Is it really necessary to overload one of the most commonly used operators with a feature that is rarely used and heavily impairs the ability to find bugs related to that operator? But I also disagree with Helgefs removal suggestion. The feature is already implemented and coded - its fairly easy to use and rather intuitive. I wouldn't want to completely remove it. I think it might be for the best if we split the operator into 2 parts: one number comparison and one string comparison. We already use the ~ prefix for regexmatch. It could also be used for this string comparison:
|
Hello, I'm not sure the following is containing anything new, it might just be a rephrasing (but maybe a clarification) of what I have already tried to say.
my_less_than(var1, var2) {
if (type(var1) == 'Integer' || type(var1) == 'Float') && (type(var2) == 'Integer' || type(var2) == 'Float')
return var1 < var2
throw
}
You have exemplified one of the only good candidates for built-in variables, constant values which can be resolved at load time, such as
That is clear, it should also be clear that I think you underestimate the issue and exaggerate the usefulness of being able of to do string compairsons with the operators.
It was not a bad idea, it solved the need to do The greatest reliefs of leaving v1 in favour of v2 has been less of these kinds of quirks and smart behaviour / assumptions to keep track of, the addition of more exceptions, and the distinction between string and number types. My proposed changes are in line with this, imo.
The topic was touched on, in a recent thread, no-one agreed with me, one agreed with you. I am not trying to wear down your resistance, I recognise the fact that your view on the language is based on much more experience and knowledge of both implementation and usage, I respect that.
I probably misunderstood what I quoted.
So now you need verbosity 😉 ? I meant it to be an object with a
It looks messy to me.
I like it very much 😉 .
That is fine then, but
It needs only be backwards-compatible within ahk @nnnik, it is not a bad suggestion, I thought of having a separate set of operators too, but couldn't think of any good ones. It could also handle dependency on It also makes it harder to have compairsons with I am biased against the prefix Cheers. |
I have not seen ~< been used in any way before therefore I dont think we should pay any mind to the collision. Also |
Hello 👋. No I do not suggest that. Disregarding my initial associations, the fact that Btw, I do not value the meaning of Cheers. |
Since I started using:
In theory, I wouldn't mind if Keeping/removing string comparison; I consider both situations below. VerCompareI'd recommend VerCompare be a built-in function. Relevant code: How to check if an IPv6 address belongs to a network? But for dot-delimited strings, not arrays. Maintaining string comparison: possibilitiesIf string comparison were maintained for the operators, we should probably always ignore type, so that we have simple easy-to-remember rules. If two items look numeric, they should be compared numerically. The finer points are considered here: Note: re. numeric/string comparison, this issue remains: Bug: StrSplit. (Since types would be ignored, StrCompare would be used to force a string comparison. Or perhaps StrOp or one of the other ideas below.) Or if type were to be considered, when doing comparisons: Int/Float/Num and Str functions could force numeric/string comparisons. Removing string comparison: possibilitiesStrCompare: StrOp: StrMatch: [EDIT:] Array functionality: Operators (not recommended, because the symbols are ugly and too numerous): Further pointsOther potential innovations: StrEquals: Changing/removing A_StringCaseSense (not recommended): Redefining operators/operator overloading: Modes for operators: |
Split from #107.