ARexx "not not" bug

A forum for general AmigaOS 4.x support questions that are not platform-specific
User avatar
polluks
Posts: 55
Joined: Tue May 19, 2015 6:30 pm
Location: Germany
Contact:

ARexx "not not" bug

Post by polluks »

Hi!

Works

Code: Select all

rx "say ~(~0)"
Does not work

Code: Select all

rx "say ~~0"
30 years hidden :o
User avatar
thomasrapp
Posts: 310
Joined: Sat Jun 18, 2011 11:22 pm

Re: ARexx "not not" bug

Post by thomasrapp »

Not really a bug. It does not give wrong results, it issues an error message. So it's more a restriction than a bug.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: ARexx "not not" bug

Post by broadblues »

polluks wrote:Hi!

Works

Code: Select all

rx "say ~(~0)"
Does not work

Code: Select all

rx "say ~~0"
30 years hidden :o
Definetly not a bug at all. Operators are made of 1 or 2 symbols so '|' and '||' are both valid operators with different meaning, first means 'or' second means 'concatenate' . '~' means 'not' but '~~' has no meaning assigned therefore throws up an error

If by some chance you really need 'not not' you need to use parenthesis, as in your first expression, though most usualy you can probably simplify you expression to remove the nots as they cancel out.

Fairly sure the same would work in C (!! expression) would give an error. !(! expression) would work.
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: ARexx "not not" bug

Post by salass00 »

broadblues wrote: Fairly sure the same would work in C (!! expression) would give an error. !(! expression) would work.
Actually "!!value" does work in C and is commonly used to normalize arbitrary zero/non-zero boolean values into being either 0 or 1 for false and true respectively.
User avatar
thomasrapp
Posts: 310
Joined: Sat Jun 18, 2011 11:22 pm

Re: ARexx "not not" bug

Post by thomasrapp »

~~ also works in Rexx on IBM mainframe.
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1714
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: ARexx "not not" bug

Post by nbache »

thomasrapp wrote:~~ also works in Rexx on IBM mainframe.
Interesting - what does it work as? Because my recollection from when I used Rexx on IBM mainframes was that the logical NOT operator isn't a tilde at all, but a proper "not" sign ("¬") or alternatively a backslash.

The tilde as NOT is an ARexx speciality.

Best regards,

Niels
User avatar
thomasrapp
Posts: 310
Joined: Sat Jun 18, 2011 11:22 pm

Re: ARexx "not not" bug

Post by thomasrapp »

nbache wrote:
thomasrapp wrote:my recollection from when I used Rexx on IBM mainframes was that the logical NOT operator isn't a tilde at all, but a proper "not" sign ("¬")

Sorry, I wasn't clear. Of course I didn't try ~~ but the equivalent of "NOT NOT" which is ^^ using the German code page.
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1714
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: ARexx "not not" bug

Post by nbache »

thomasrapp wrote:Sorry, I wasn't clear. Of course I didn't try ~~ but the equivalent of "NOT NOT" which is ^^ using the German code page.
Ah, right. Yes, I also remember the caret being an alternative with some charsets.

Anyway, since each implementation of the language obviously has its own choices regarding (among other things) operator implementation, I don't regard it as a bug that the ARexx implementation parses the double NOT as one two-character operator (which happens to be undefined) rather than two consecutive NOT operators.

There are several other, larger differences between ARexx and Rexx; IIRC a number of builtin functions in ARexx are not found in Rexx. The author had good reason to name his implementation ARexx rather than Rexx for Amiga or similar.

Best regards,

Niels
User avatar
polluks
Posts: 55
Joined: Tue May 19, 2015 6:30 pm
Location: Germany
Contact:

Re: ARexx "not not" bug

Post by polluks »

Sorry guys, all prefix operators are broken:

Code: Select all

say --1
say ++1
If you take a look in the "bible":
"There may be one or more prefix operators to the left of any term."
https://books.google.de/books?hl=de&id= ... refix+plus

C'mon, our implementation is not a decision by design but simply incomplete.
It's slower, you have to parse extra parentheses.
User avatar
thomasrapp
Posts: 310
Joined: Sat Jun 18, 2011 11:22 pm

Re: ARexx "not not" bug

Post by thomasrapp »

What sense does it make to invert an inverting operator? Instead of ~~0 you could write just 0. Would be even faster, no operator to parse at all.
Post Reply