Difference between revisions of "Category talk:LSL Operators"

From Second Life Wiki
Jump to navigation Jump to search
m (Created page with '== Operator Associativity == some of the operator associations such as && || are actually left to right, (0 && 0 || 1) == TRUE, (1 || 0 && 0) == FAlSE, and are easy to list as su...')
 
m (updated comment)
Line 1: Line 1:
== Operator Associativity ==
== Operator Associativity ==
some of the operator associations such as && || are actually left to right, (0 && 0 || 1) == TRUE, (1 || 0 && 0) == FAlSE, and are easy to list as such, but I'm assuming that single operator precedence levels (like bitwise &) are preferred to be listed in the compiled code order (right to left), where testing shows that order doesn't matter to execution? originally I had listed those as left to right as a matter of convenience, but I can see the value of reinforcing the knowledge that LSL is compiled in general right to left asociation, with exceptions to certain operations. I'm still testing some precedence associations, so I'll update as that occurs. <br/>-- '''[[User:Void_Singer|Void]]''' <sup><small>([[User_talk:Void_Singer|talk]]|[[Special:Contributions/Void_Singer|contribs]])</small></sup> 03:29, 11 January 2010 (UTC)
some of the operator associations such as && || are actually left to right, (0 && 0 || 1) == TRUE, (1 || 0 && 0) == FAlSE, and are easy to list as such, but I'm assuming that single operator precedence levels (like bitwise &) are preferred to be listed in the compiled code order (right to left), where testing shows that order doesn't matter to execution? originally I had listed those as left to right as a matter of convenience, but I can see the value of reinforcing the knowledge that LSL is compiled in general right to left asociation, with exceptions to certain operations. I'm still testing some precedence associations, so I'll update as that occurs. <br/>-- '''[[User:Void_Singer|Void]]''' <sup><small>([[User_talk:Void_Singer|talk]]|[[Special:Contributions/Void_Singer|contribs]])</small></sup> 03:29, 11 January 2010 (UTC)
: update:<br> all infix math operators are LtR (not suprising as they'd have issues otherwise), as are bitshift, and comparison operators, as demonstrated by the following equations that all evaluate to true in LSL<br>((4 / 2 / 2) != (4 / (2 / 2)))<br>((1 + 1 - 1 + 1) != (1 + (1 -( 1 + 1)))<br>(2 >> 1 >> 1) != (2 >> (1 >> 1))<br>(1 > 1 > 1) != (1 > (1 > 1))<br>(2 == 2 == 1) != (2 == (2 == 1))<br>(0 && 0 || 1) != (0 && (0 || 1))<br>this kinda makes me wonder about the other bitwise operators, although as far as I can tell there's no way to confirm their associativity (IIRC &|^ operations are nonassociative with themselves in the mathematical sense, similar to addition by itself) <br/>-- '''[[User:Void_Singer|Void]]''' <sup><small>([[User_talk:Void_Singer|talk]]|[[Special:Contributions/Void_Singer|contribs]])</small></sup> 05:36, 11 January 2010 (UTC)

Revision as of 22:36, 10 January 2010

Operator Associativity

some of the operator associations such as && || are actually left to right, (0 && 0 || 1) == TRUE, (1 || 0 && 0) == FAlSE, and are easy to list as such, but I'm assuming that single operator precedence levels (like bitwise &) are preferred to be listed in the compiled code order (right to left), where testing shows that order doesn't matter to execution? originally I had listed those as left to right as a matter of convenience, but I can see the value of reinforcing the knowledge that LSL is compiled in general right to left asociation, with exceptions to certain operations. I'm still testing some precedence associations, so I'll update as that occurs.
-- Void (talk|contribs) 03:29, 11 January 2010 (UTC)

update:
all infix math operators are LtR (not suprising as they'd have issues otherwise), as are bitshift, and comparison operators, as demonstrated by the following equations that all evaluate to true in LSL
((4 / 2 / 2) != (4 / (2 / 2)))
((1 + 1 - 1 + 1) != (1 + (1 -( 1 + 1)))
(2 >> 1 >> 1) != (2 >> (1 >> 1))
(1 > 1 > 1) != (1 > (1 > 1))
(2 == 2 == 1) != (2 == (2 == 1))
(0 && 0 || 1) != (0 && (0 || 1))
this kinda makes me wonder about the other bitwise operators, although as far as I can tell there's no way to confirm their associativity (IIRC &|^ operations are nonassociative with themselves in the mathematical sense, similar to addition by itself)
-- Void (talk|contribs) 05:36, 11 January 2010 (UTC)