<> no longer acceptable as a comparison operator
- JoeWinograd
- Posts: 2182
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
<> no longer acceptable as a comparison operator
Just upgraded to 2.0-a099-ca386dc (64-bit) and my statements with <> as the not-equal comparison operator no longer work. Changing the <> to != fixes them. Bug or feature? If the latter, just curious...why? Doesn't seem like the sort of syntax change that will improve the usability and convenience of the language, but the lack of backward compatibility in this case will break a ton of scripts. Btw, <> works fine on 2.0-a097-60f26de (64-bit). Regards, Joe
- JoeWinograd
- Posts: 2182
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: <> no longer acceptable as a comparison operator
Thanks, Helgef. Do you know what the thinking was on removing it?
Re: <> no longer acceptable as a comparison operator
simplification and keeping parity with the new case-sensitive string compare not equal operator !==. probably.
- JoeWinograd
- Posts: 2182
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: <> no longer acceptable as a comparison operator
Thanks for the thought, swagfag. That "simplification" is a real nuisance here. Just did a quick search for all my AHK scripts containing <> — 597 of 'em! OK, lots of versioning in that total, but even so, probably a couple of hundred scripts. I doubt that I've ever written a script that doesn't have at least one If (ErrorLevel<>0) in it. Fortunately, I can't think of any other usage for the pair (without intervening text), so a simple global replace of <> with != is probably safe.
Re: <> no longer acceptable as a comparison operator
semantically i think <> doesn't really make any sense for "not equal" and therefore makes code less readable
- JoeWinograd
- Posts: 2182
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: <> no longer acceptable as a comparison operator
Good point! Guess I just got very used to it.guest3456 wrote:makes code less readable
Re: <> no longer acceptable as a comparison operator
- Is this not actually quite logical?
- Sure it makes sense that = and !=, (and, == and !==) should be exact opposites, they are not in AHK v1. Confusingly (a != b) and !(a = b) were not equivalent. (It was a good idea to change != and add !==.)
- However, now that I think about it, I don't see any particular reason to remove <>.
Code: Select all
a < b [a is less than b]
a = b [a is equal to b]
a <= b [a is less than or equal to b]
a < b [a is less than b]
a > b [a is greater than b]
a <> b [a is less than or greater than b][a is not equal to b]
- However, now that I think about it, I don't see any particular reason to remove <>.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: <> no longer acceptable as a comparison operator
I think it's ambiguous, for example, when comparing two objects. What is it that an object is smaller or greater than another value?.a <> b [a is less than or greater than b][a is not equal to b]
Re: <> no longer acceptable as a comparison operator
No the real question is why <> is preferred over >< which sort of looks like an anime face in my opinion.
Anyways semantically, it seems easier to read ! as not and = as equal.
Anyways semantically, it seems easier to read ! as not and = as equal.
- JoeWinograd
- Posts: 2182
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: <> no longer acceptable as a comparison operator
You're right...it is.Is this not actually quite logical?
I agree.However, now that I think about it, I don't see any particular reason to remove <>.
Well, I don't think that's "the real question", but the answer is, because <> already exists, is documented in V1, and surely has been used in a gazillion scripts, while >< does not already exist. Btw, I would expect If (a><b) to generate a compiler error in V1...it doesn't! But it also doesn't work as a not-equal test...it always evaluates to False!No the real question is why <> is preferred over ><
Same as with anything else...means it's not equal.What is it that an object is smaller or greater than another value?
I get the idea that V2 is not shackled by any backward compatibility concerns and is willing to change to improve the usability and convenience of the language...I'm all for it. That said, I don't think it should make changes that break existing code (albeit easily fixed) when such changes have no impact on the usability and convenience of the language. Regards, Joe
- JoeWinograd
- Posts: 2182
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: <> no longer acceptable as a comparison operator
Btw, in the Help text, where it shows:
not-equal (<> or !=)
Should <> be marked as deprecated?
not-equal (<> or !=)
Should <> be marked as deprecated?
Re: <> no longer acceptable as a comparison operator
I can't find that on this page https://lexikos.github.io/v2/docs/Variables.htm
- JoeWinograd
- Posts: 2182
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: <> no longer acceptable as a comparison operator
I mean marking it deprecated in the V1 Help text (not V2), along with IfEqual, IfNotEqual, IfExist, IfInString, etc., i.e., all the language elements that work in V1, but are marked as deprecated. I take "deprecated" to mean not supported in V2, although I could be wrong about its definition. If "deprecated" does not mean unsupported in V2, what does it mean? I can't imagine that all the language elements marked as deprecated in the V1 Help text would ever be dropped in any future V1 release...that would result in untold havoc in the AHK community. The only reasonable meaning that I can see for "deprecated" is that it won't be in V2. Regards, Joe
Re: <> no longer acceptable as a comparison operator
Hey I'm pretty sure that "deprecated" is a fancy term for "we made some poor design choices, and now that we have this new way of doing things, please use that."
In this case, IfEqual, IfNotEqual, IfExist, IfInString have been replaced with if (expression) so it's really not recommended to use IfEqual but it's there because some user might google up an old script and expect it to work. I think that v2 will make several breaking changes to the language, so it's aim isn't backwards compatibility. So deprecated might refer to the AHK Basic -> AutoHotkey_L transition, but I could be mistaken.
In this case, IfEqual, IfNotEqual, IfExist, IfInString have been replaced with if (expression) so it's really not recommended to use IfEqual but it's there because some user might google up an old script and expect it to work. I think that v2 will make several breaking changes to the language, so it's aim isn't backwards compatibility. So deprecated might refer to the AHK Basic -> AutoHotkey_L transition, but I could be mistaken.
- JoeWinograd
- Posts: 2182
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: <> no longer acceptable as a comparison operator
Yes, "please use that" is fine. But it would be incomprehensible to me if any future release of V1 stopped accepting the language elements now marked as "deprecated" in the V1 doc."deprecated" is a fancy term for "we made some poor design choices, and now that we have this new way of doing things, please use that."
Sure, it's recommended not to use the language elements now marked as deprecated, but they certainly better continue to work in all V1 releases.it's really not recommended to use
That's a tiny portion of why it's there. The overwhelming reason why it's there is because of all the scripts written by all the AHK users/developers all over the world, for both personal use and commercial use. None of that has anything to do with googling up an old script. It has everything to do with all the scripts that all of us have written.it's there because some user might google up an old script and expect it to work
Yes, and, as I've already stated, I'm good with that. Regards, JoeI think that v2 will make several breaking changes to the language
Re: <> no longer acceptable as a comparison operator
I always thought <> has always been marked as deprecated.
tbh it was a poor design choice.
tbh it was a poor design choice.
Recommends AHK Studio
- JoeWinograd
- Posts: 2182
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: <> no longer acceptable as a comparison operator
It's not marked as such in the V1 doc.nnnik wrote:I always thought <> has always been marked as deprecated.
Perhaps, but I'm fine with it as an equivalent to !=, which is how the V1 doc states it:nnnik wrote:tbh it was a poor design choice.
Regards, JoeThe operators != and <> are identical in function.
Re: <> no longer acceptable as a comparison operator
OK I will add a deprecated notice to the docs and make a PR.
Recommends AHK Studio
- JoeWinograd
- Posts: 2182
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: <> no longer acceptable as a comparison operator
Sounds good.
Return to “AutoHotkey Development”
Who is online
Users browsing this forum: No registered users and 39 guests