
squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2014
02:22 PM
If not
Is there a difference between these two statements?
if not m.motionbit = invalid
if m.motionbit <> invalid
thanks
if not m.motionbit
if m.motionbit
thanks
Kinetics Screensavers
6 REPLIES 6
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2014
03:15 PM
Re: If not
"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.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2014
03:17 PM
Re: If not
Potentially. Depends on the type of "m.motionbit". If it were a boolean, for instance, then your first statement would compare it's inverse to invalid (which would probably cause a type mismatch). There is no difference between these two statements, though:
Note the parentheses enforce the priority of how the expression is evaluated, so the equality gets evaluated prior to having the "Not" applied to it.
if not (m.motionbit[x] = invalid)
if m.motionbit[x] <> invalid
Note the parentheses enforce the priority of how the expression is evaluated, so the equality gets evaluated prior to having the "Not" applied to it.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2014
03:30 PM
Re: If not
Fascinating. Thank you both.
Kinetics Screensavers
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2014
05:40 PM
Re: If not
"TheEndless" wrote:
Potentially. Depends on the type of "m.motionbit". If it were a boolean, for instance, then your first statement would compare it's inverse to invalid
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
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.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2014
06:15 PM
Re: If not
"EnTerr" wrote:"TheEndless" wrote:
Potentially. Depends on the type of "m.motionbit". If it were a boolean, for instance, then your first statement would compare it's inverse to invalid
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= invalid then ... , 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?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2014
06:45 PM
Re: If not
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".
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".