Order operations spin (NOOB question)
PE Kit lab book v1.2 page 91
if Cog
cogStop(cog~ - 1)
If ~ is on a higher level than - 1 why is - 1 evaluated first?
Reference http://nagasm.org/ASL/Propeller/printedPDF/QuickReference-v15.pdf
if Cog
cogStop(cog~ - 1)
If ~ is on a higher level than - 1 why is - 1 evaluated first?
Reference http://nagasm.org/ASL/Propeller/printedPDF/QuickReference-v15.pdf
Comments
- is precedence level 6 and is subtract.
The key point here is the "post", as in "after".
So what you have in "cogStop(cog~ - 1)" is:
1) Take the value of cog into some internal temporary value.
2) Set the value of cog to zero.
3) Subtract one from that internal temporary value.
4) Pass the temporary value to cogStop as a parameter.
x~ clears x but returns the old value of x. Just like how x++ increments x but returns the old value of x (while ++x increments x but returns the new value instead of the old).