AmiBlitz / AmiBlitz3

Complete package of AmiBlitz3 including all sources.
https://www.amiblitz.de/
123 stars 9 forks source link

If doen't work correctly with NOT #82

Closed Nju79 closed 1 year ago

Nju79 commented 1 year ago

Following Code writes every time "Yep" in the console:

a.b = 10 b.b = 5 If NOT a = 9 AND b = 6 Then Print "Yep" END

If I change the code to

a.b = 10 b.b = 5 If NOT a = 9 AND b = 5 Then Print "Yep" END

the same behaviour occurs. In my opinion the and b = x is completly ignoring by the compiler, isn't it?

mdbergmann commented 1 year ago

Maybe AND binds higher than NOT, in which case your results were OK. Did try grouping with parenthesis?

Nju79 commented 1 year ago

Why there should be a priority binding there if both examples above come to the same result?

mdbergmann commented 1 year ago

Just saying. I couldn't find a something in the language specs about the binding strengths. But if = binds higher than AND, and AND binds higher than NOT, then both of your outcomes are correct, because:

a = 9 AND b = 6 and a = 9 AND b = 5 is false, negating it makes it true, hence "Yep" is printed.

But this is just assumption. I don't know what binds higher.

Nju79 commented 1 year ago

Thank you for your explanation. I've cross-tested this and it seems like AND has a higher binding than NOT. Parenthesis like (NOT a = 9) seems to be working.