If not

Is there a difference between these two statements?

if not m.motionbit

“squirreltown” wrote:
Is there a difference between these two statements?

if not m.motionbit[x] = invalid

if m.motionbit[x] <> invalid

No, they are the same.
“not” has lower precedence than comparison so things are allright.
You can use “da” in console to look at the bytecode when in doubt.

Potentially. Depends on the type of "m.motionbit

Fascinating. Thank you both.

“TheEndless” wrote:
Potentially. Depends on the type of "m.motionbit
Nope - it does not depend at all on the value.
Operations are performed in order of precedence, as provided in TFM. In the case of if not m.motionbit, dot-operator has highest priority and goes first, followed by , followed by comparison operator, and NOT is last. In other words, it is the same as this (which by the way works too):

if (not ( ( (m.motionbit)[x] ) = invalid) ) then ...

The order/precedence of the operations has been done in such a way to minimize need for parenthesis in day-to-day coding.

“EnTerr” wrote:

“TheEndless” wrote:
Potentially. Depends on the type of "m.motionbit
Nope - it does not depend at all on the value.
Operations are performed in order of precedence, as provided in TFM. In the case of if not m.motionbit, dot-operator has highest priority and goes first, followed by , followed by comparison operator, and NOT is last. In other words, it is the same as this (which by the way works too):

if (not ( ( (m.motionbit)[x] ) = invalid) ) then ...

The order/precedence of the operations has been done in such a way to minimize need for parenthesis in day-to-day coding.
I guess I should have tried it first. But I think the better question is why would you want to “Not” a check for equality, instead of directly checking for inequality? What’s the use-case in which you’d want/need to do that?

Well, docendo discimus.
It’s useful to understand how expressions are evaluated/calculated in principle. There is some order and logic in how B/S works - aside from the half-documented, no-type-checks roComponents - or i would have forsaken it by now as “another PHP / mySQL”. I am quite interested where the VM underneath comes from but doubt someone will tell me.

And of course, “when in doubt - use parenthesis”.