AmiBlitz/AmiBlitz3

If doen't work correctly with NOT

Closed this issue · 4 comments

Nju79 commented

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?

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

Nju79 commented

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

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

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.