Difference between revisions of "Category:LSL Operators"
Jump to navigation
Jump to search
Void Singer (talk | contribs) m (updating) |
(→Operator Precedence (Order of Operations): All of the bytecode operators in LSO are backwards, which is why it's Right to Left. Only list expressions and function parameters are executed left to) |
||
Line 19: | Line 19: | ||
| , | | , | ||
|| Comma | || Comma | ||
|| Left to Right | || Left to Right{{Footnote|handle=1|Both the Comma and the Assignment Operators are special cases. Commas promote all Operators to the left. | ||
However within parenthesis and brackets obey those respective precedences.}} | |||
|- | |- | ||
| ++ -- | | ++ -- | ||
Line 31: | Line 32: | ||
| /<br>%<br>*<br><nowiki>|</nowiki><br>^ | | /<br>%<br>*<br><nowiki>|</nowiki><br>^ | ||
|| Division<br>Modulus<br>Multiplication<br>Bitwise OR<br>Bitwise eXclusive OR | || Division<br>Modulus<br>Multiplication<br>Bitwise OR<br>Bitwise eXclusive OR | ||
|| Left | || Right to Left | ||
|- | |- | ||
| +<br>- | | +<br>- | ||
|| Addition/Concatenation<br>Subtraction | || Addition/Concatenation<br>Subtraction | ||
|| Left | || Right to Left | ||
|- | |- | ||
| << >> | | << >> | ||
|| Bitwise Shift Left/Right | || Bitwise Shift Left/Right | ||
|| Left | || Right to Left | ||
|- | |- | ||
| < ><br><= >= | | < ><br><= >= | ||
|| Less/Greater Than<br>Less/Greater Than or Equal | || Less/Greater Than<br>Less/Greater Than or Equal | ||
|| Left | || Right to Left | ||
|- | |- | ||
| == != | | == != | ||
|| Equivalent/NOT Equivalent | || Equivalent/NOT Equivalent | ||
|| Left | || Right to Left | ||
|- | |- | ||
| & | | & | ||
|| Bitwise AND | || Bitwise AND | ||
|| Left | || Right to Left | ||
|- | |- | ||
| ^ | | ^ | ||
|| Bitwise eXclusive OR | || Bitwise eXclusive OR | ||
|| Left | || Right to Left | ||
|- | |- | ||
| <nowiki>|</nowiki> | | <nowiki>|</nowiki> | ||
|| Bitwise OR | || Bitwise OR | ||
|| Left | || Right to Left | ||
|- | |- | ||
| && <nowiki>||</nowiki> | | && <nowiki>||</nowiki> | ||
|| Logical AND / OR | || Logical AND / OR | ||
|| Left | || Right to Left | ||
|- | |- | ||
| =<br>+= -= /= %= *= | | =<br>+= -= /= %= *= | ||
|| Assignment<br>Additive/Subtractive/Divisive/Modulo/Multiplicative Assignment | || Assignment<br>Additive/Subtractive/Divisive/Modulo/Multiplicative Assignment | ||
|| Right to Left | || Right to Left{{Footnote|handle=1}} | ||
|} | |} | ||
{{Footnotes}} | |||
<lsl>//-- example: | <lsl>//-- example: | ||
float a; | float a; | ||
Line 100: | Line 99: | ||
} | } | ||
}</lsl> | }</lsl> | ||
=== Right To Left ==== | |||
* Placeholder for commentary about the LSL compiler and LSO R2L implications. |
Revision as of 16:46, 10 January 2010
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Page recreated to house the future revision of the LSL_Operators page into categorized Content. Please do not delete.
if you're looking for the current version, it may be found at LSL_Operators.
Operator Precedence (Order of Operations)
current rough draft of precedence
Operator | Description | Associativity |
---|---|---|
() [] |
Parenthesis List Constructor |
Inner to Outer then Right to Left |
, | Comma | Left to Right[1] |
++ -- | Increment/Decrement | Right to Left |
(type) ~ ! - |
Typecast Bitwise NOT Logical NOT Negation |
Right to Left |
/ % * | ^ |
Division Modulus Multiplication Bitwise OR Bitwise eXclusive OR |
Right to Left |
+ - |
Addition/Concatenation Subtraction |
Right to Left |
<< >> | Bitwise Shift Left/Right | Right to Left |
< > <= >= |
Less/Greater Than Less/Greater Than or Equal |
Right to Left |
== != | Equivalent/NOT Equivalent | Right to Left |
& | Bitwise AND | Right to Left |
^ | Bitwise eXclusive OR | Right to Left |
| | Bitwise OR | Right to Left |
&& || | Logical AND / OR | Right to Left |
= += -= /= %= *= |
Assignment Additive/Subtractive/Divisive/Modulo/Multiplicative Assignment |
Right to Left[1] |
- ^ Both the Comma and the Assignment Operators are special cases. Commas promote all Operators to the left. However within parenthesis and brackets obey those respective precedences.
<lsl>//-- example: float a; float b; float c;
string uExample( float x, float y ){
return (string)x + " " + (string)y;
}
default{
state_entry(){ string vStrReport = "\n" + (string)(++a) + " " + (string)(++a); //-- first line reports "2.000000 1.000000" vStrReport += "\n" + (string)[++b, " ", ++b]; //-- second line reports "1.000000 2.000000" vStrReport += "\n" + uExample( ++c, ++c ); //-- third line reports "1.000000 2.000000" llOwnerSay( vStrReport ); }
}</lsl> Assigment operators Demote all precedences to the Left of them (but obey all precedences below above increment/decrement. <lsl>//-- example: integer a;
default{
state_entry(){ llOwnerSay( (string)(++a + a *= ++a) ); //-- yields "3" instead of "4" }
}</lsl>
Right To Left =
- Placeholder for commentary about the LSL compiler and LSO R2L implications.