ARexx "not not" bug

A forum for general AmigaOS 4.x support questions that are not platform-specific

ARexx "not not" bug

Postby polluks » Fri Apr 21, 2017 3:56 pm

Hi!

Works
Code: Select all
rx "say ~(~0)"

Does not work
Code: Select all
rx "say ~~0"

30 years hidden :o
User avatar
polluks
 
Posts: 16
Joined: Tue May 19, 2015 7:30 pm
Location: Germany

Re: ARexx "not not" bug

Postby thomasrapp » Fri Apr 21, 2017 4:25 pm

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
thomasrapp
 
Posts: 241
Joined: Sun Jun 19, 2011 12:22 am

Re: ARexx "not not" bug

Postby broadblues » Fri Apr 21, 2017 5:09 pm

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
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 480
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: ARexx "not not" bug

Postby salass00 » Fri Apr 21, 2017 7:24 pm

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
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 485
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

Re: ARexx "not not" bug

Postby thomasrapp » Fri Apr 21, 2017 7:36 pm

~~ also works in Rexx on IBM mainframe.
User avatar
thomasrapp
 
Posts: 241
Joined: Sun Jun 19, 2011 12:22 am

Re: ARexx "not not" bug

Postby nbache » Fri Apr 21, 2017 11:33 pm

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
nbache
Beta Tester
Beta Tester
 
Posts: 1211
Joined: Mon Dec 20, 2010 8:25 pm
Location: Copenhagen, Denmark

Re: ARexx "not not" bug

Postby thomasrapp » Sat Apr 22, 2017 10:49 am

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
thomasrapp
 
Posts: 241
Joined: Sun Jun 19, 2011 12:22 am

Re: ARexx "not not" bug

Postby nbache » Sat Apr 22, 2017 6:03 pm

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
nbache
Beta Tester
Beta Tester
 
Posts: 1211
Joined: Mon Dec 20, 2010 8:25 pm
Location: Copenhagen, Denmark

Re: ARexx "not not" bug

Postby polluks » Sun Apr 23, 2017 12:47 am

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
polluks
 
Posts: 16
Joined: Tue May 19, 2015 7:30 pm
Location: Germany

Re: ARexx "not not" bug

Postby thomasrapp » Sun Apr 23, 2017 8:48 am

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.
User avatar
thomasrapp
 
Posts: 241
Joined: Sun Jun 19, 2011 12:22 am

Next

Return to General AmigaOS

Who is online

Users browsing this forum: No registered users and 1 guest

cron