<> no longer acceptable as a comparison operator

Discuss the future of the AutoHotkey language
User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

<> no longer acceptable as a comparison operator

09 Sep 2018, 12:35

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
User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: <> no longer acceptable as a comparison operator

09 Sep 2018, 13:49

Thanks, Helgef. Do you know what the thinking was on removing it?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: <> no longer acceptable as a comparison operator

09 Sep 2018, 15:28

simplification and keeping parity with the new case-sensitive string compare not equal operator !==. probably.
User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: <> no longer acceptable as a comparison operator

09 Sep 2018, 15:52

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.
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: <> no longer acceptable as a comparison operator

09 Sep 2018, 20:29

semantically i think <> doesn't really make any sense for "not equal" and therefore makes code less readable

User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: <> no longer acceptable as a comparison operator

09 Sep 2018, 20:51

guest3456 wrote:makes code less readable
Good point! Guess I just got very used to it. :)
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: <> no longer acceptable as a comparison operator

09 Sep 2018, 20:58

- Is this not actually quite logical?

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]
- 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 <>.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: <> no longer acceptable as a comparison operator

09 Sep 2018, 21:37

a <> b [a is less than or greater than b][a is not equal to b]
I think it's ambiguous, for example, when comparing two objects. What is it that an object is smaller or greater than another value?.
iseahound
Posts: 1434
Joined: 13 Aug 2016, 21:04
Contact:

Re: <> no longer acceptable as a comparison operator

10 Sep 2018, 07:25

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.
User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: <> no longer acceptable as a comparison operator

10 Sep 2018, 16:50

Is this not actually quite logical?
You're right...it is.
However, now that I think about it, I don't see any particular reason to remove <>.
I agree.
No the real question is why <> is preferred over ><
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!
What is it that an object is smaller or greater than another value?
Same as with anything else...means it's not equal.

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
User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: <> no longer acceptable as a comparison operator

12 Sep 2018, 19:22

Btw, in the Help text, where it shows:

not-equal (<> or !=)

Should <> be marked as deprecated?
User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: <> no longer acceptable as a comparison operator

12 Sep 2018, 19:55

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
iseahound
Posts: 1434
Joined: 13 Aug 2016, 21:04
Contact:

Re: <> no longer acceptable as a comparison operator

12 Sep 2018, 20:31

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.
User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: <> no longer acceptable as a comparison operator

12 Sep 2018, 20:58

"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."
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.
it's really not recommended to use
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 there because some user might google up an old script and expect it to work
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.
I think that v2 will make several breaking changes to the language
Yes, and, as I've already stated, I'm good with that. Regards, Joe
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: <> no longer acceptable as a comparison operator

13 Sep 2018, 02:18

I always thought <> has always been marked as deprecated.
tbh it was a poor design choice.
Recommends AHK Studio
User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: <> no longer acceptable as a comparison operator

13 Sep 2018, 10:52

nnnik wrote:I always thought <> has always been marked as deprecated.
It's not marked as such in the V1 doc.
nnnik wrote:tbh it was a poor design choice.
Perhaps, but I'm fine with it as an equivalent to !=, which is how the V1 doc states it:
The operators != and <> are identical in function.
Regards, Joe
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: <> no longer acceptable as a comparison operator

13 Sep 2018, 11:16

OK I will add a deprecated notice to the docs and make a PR.
Recommends AHK Studio
User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: <> no longer acceptable as a comparison operator

13 Sep 2018, 11:21

Sounds good.

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 37 guests