Difference between revisions of "Category:LSL Operators"

From Second Life Wiki
Jump to: navigation, search
m (Operator Precedence (Order of Operations))
m (Fleshing out the page)
Line 4: Line 4:
 
if you're looking for the current version, it may be found at [[LSL_Operators]].
 
if you're looking for the current version, it may be found at [[LSL_Operators]].
  
== Operator Precedence (Order of Operations) ==
+
{{void-box
 
+
|title=Operator Precedence (Order of Operations)
current rough draft of precedence
+
|content=
{| bgcolor="#FFFFFF" border="1"  cellspacing="2" cellpadding="6"
+
{{{!}} bgcolor="#FFFFFF" border="1"  cellspacing="2" cellpadding="6"
|- bgColor="#A7C1F2"
+
{{!}}- bgColor="#A7C1F2"
 
! Operator
 
! Operator
 
! Description
 
! Description
! Associativity
+
! Direction
|-
+
{{!}}- bgColor="#E0E0E0"
| ()<br>[]
+
{{!}} ,
|| Parenthesis<br>List Constructor
+
{{!}}{{!}} Separator
|| Inner to Outer<br>then<br>Right to Left
+
{{!}}{{!}} Left to Right{{Footnote|handle=1|Separators promote ALL operators to the left until the first unmatched, from it's position,  open-bracket or open-parenthesis. This precedence ONLY applies within the brackets/parenthesis containing it}}
|-
+
{{!}}-
| ,
+
{{!}}
|| Comma
+
++<br>
|| Left to Right{{Footnote|handle=1|Both the Comma and the Assignment Operators are special cases. Commas promote all Operators to the left.
+
--<br>
However within parenthesis and brackets obey those respective precedences.}}
+
.<br>
|-
+
&nbsp;
| ++ --
+
{{!}}{{!}}
|| Increment/Decrement
+
Increment<br>
|| Right to Left
+
Decrement<br>
|-
+
Element Selector<br>
| (type)<br>~<br>!<br>-
+
(also Variable Evaluation)
|| Typecast<br>Bitwise NOT<br>Logical NOT<br>Negation
+
{{!}}{{!}} Right to Left
|| Right to Left
+
{{!}}- bgColor="#E0E0E0"
|-
+
{{!}}
| /<br>%<br>*<br><nowiki>|</nowiki><br>^
+
=<br>
|| Division<br>Modulus<br>Multiplication<br>Bitwise OR<br>Bitwise eXclusive OR
+
+=<br>
|| Right to Left
+
-=<br>
|-
+
/=<br>
| +<br>-
+
%=<br>
|| Addition/Concatenation<br>Subtraction
+
<nowiki>*=</nowiki>
|| Right to Left
+
{{!}}{{!}}
|-
+
Direct Assignment<br>
| << >>
+
Addition/Concatenation Assignment<br>
|| Bitwise Shift Left/Right
+
Subtraction Assignment<br>
|| Right to Left
+
Division Assignment<br>
|-
+
Modulo/Cross-Product Assignment<br>
| < ><br><= >=
+
Multiplication/Dot-Product Assignment
|| Less/Greater Than<br>Less/Greater Than or Equal
+
{{!}}{{!}}
|| Right to Left
+
Right to Left{{Footnote|handle=2|Assignment operators promote ALL operators to the right until the first un-bracketed/praenthesized separator, unmatched close bracket or close parenthesis, or semicolon. This precedence ONLY applies within the brackets/parenthesis containing it}}
|-
+
{{!}}-
| == !=
+
{{!}}
|| Equivalent/NOT Equivalent
+
()<br>
|| Right to Left
+
[]
|-
+
{{!}}{{!}}
| &
+
Parenthesis<br>
|| Bitwise AND
+
List Constructor
|| Right to Left
+
{{!}}{{!}} Inner to Outer
|-
+
{{!}}-
| ^
+
{{!}}
|| Bitwise eXclusive OR
+
(type)<br>
|| Right to Left
+
~<br>
|-
+
<nowiki>!</nowiki><br>
| <nowiki>|</nowiki>
+
-
|| Bitwise OR
+
{{!}}{{!}}
|| Right to Left
+
Typecast<br>
|-
+
Bitwise NOT<br>
| && <nowiki>||</nowiki>
+
Logical NOT<br>
|| Logical AND / OR
+
Negation
|| Right to Left
+
{{!}}{{!}} Right to Left
|-
+
{{!}}-
| =<br>+= -= /= %= *=
+
{{!}}
|| Assignment<br>Additive/Subtractive/Divisive/Modulo/Multiplicative Assignment
+
/<br>
|| Right to Left{{Footnote|handle=1}}
+
%<br>
|}
+
<nowiki>*</nowiki><br>
 
+
<nowiki>|</nowiki><br>
 +
^
 +
{{!}}{{!}}
 +
Division<br>
 +
Modulus<br>
 +
Multiplication<br>
 +
Bitwise OR<br>
 +
Bitwise eXclusive OR
 +
{{!}}{{!}} Left to Right
 +
{{!}}-
 +
{{!}}
 +
+<br>
 +
-
 +
{{!}}{{!}}
 +
[[LSL_Addition|Addition/Concatenation]]<br>
 +
Subtraction
 +
{{!}}{{!}} Left to Right
 +
{{!}}-
 +
{{!}}
 +
<<<br>
 +
>>
 +
{{!}}{{!}}
 +
Bitwise Shift Left<br>
 +
Bitwise Shift Right
 +
{{!}}{{!}} Left to Right
 +
{{!}}-
 +
{{!}}
 +
<<br>
 +
><br>
 +
<=<br>
 +
>=
 +
{{!}}{{!}}
 +
Less Than<br>
 +
Greater Than<br>
 +
Less Than or Equal<br>
 +
Greater Than or Equal
 +
{{!}}{{!}} Left to Right
 +
{{!}}-
 +
{{!}}
 +
==<br>
 +
<nowiki>!=</nowiki>
 +
{{!}}{{!}}
 +
Equivalent<br>
 +
NOT Equivalent
 +
{{!}}{{!}} Left to Right
 +
{{!}}-
 +
{{!}} &
 +
{{!}}{{!}} Bitwise AND
 +
{{!}}{{!}} Left to Right
 +
{{!}}-
 +
{{!}} ^
 +
{{!}}{{!}} Bitwise eXclusive OR
 +
{{!}}{{!}} Left to Right
 +
{{!}}-
 +
{{!}} <nowiki>|</nowiki>
 +
{{!}}{{!}} Bitwise OR
 +
{{!}}{{!}} Left to Right
 +
{{!}}-
 +
{{!}}
 +
&&<br>
 +
<nowiki>||</nowiki>
 +
{{!}}{{!}}
 +
Logical AND<br>
 +
Logical OR
 +
{{!}}{{!}} Left to Right{{Footnote|handle=3|There is no Short Circuiting of Logical Operators in LSL, both operands will be evaluated regardless.}}
 +
{{!}}}
 +
=== Special Notes ===
 
{{Footnotes}}
 
{{Footnotes}}
 +
}}
  
<lsl>//-- example:
+
{{void-box
float a;
+
|title= Logical Operators
float b;
+
|content=
float c;
+
Logical Operators are operators those result is either TRUE or FAlSE.
 
+
* insert truth tables
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 = 0;
+
 
+
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.
+
{{void-box
 +
|title=Bitwise Operators
 +
|content=
 +
Bitwise Operators are similar to Logical Operators, but act on all bits of an integer simultaneously as if they were each a Boolean value.
 +
* flesh this out
 +
}}

Revision as of 05:40, 28 September 2010

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)

Operator Description Direction
, Separator Left to Right[1]

++
--
.
 

Increment
Decrement
Element Selector
(also Variable Evaluation)

Right to Left

=
+=
-=
/=
%=
*=

Direct Assignment
Addition/Concatenation Assignment
Subtraction Assignment
Division Assignment
Modulo/Cross-Product Assignment
Multiplication/Dot-Product Assignment

Right to Left[2]

()
[]

Parenthesis
List Constructor

Inner to Outer

(type)
~
!
-

Typecast
Bitwise NOT
Logical NOT
Negation

Right to Left

/
%
*
|
^

Division
Modulus
Multiplication
Bitwise OR
Bitwise eXclusive OR

Left to Right

+
-

Addition/Concatenation
Subtraction

Left to Right

<<
>>

Bitwise Shift Left
Bitwise Shift Right

Left to Right

<
>
<=
>=

Less Than
Greater Than
Less Than or Equal
Greater Than or Equal

Left to Right

==
!=

Equivalent
NOT Equivalent

Left to Right
& Bitwise AND Left to Right
^ Bitwise eXclusive OR Left to Right
| Bitwise OR Left to Right

&&
||

Logical AND
Logical OR

Left to Right[3]

Special Notes

  1. ^ Separators promote ALL operators to the left until the first unmatched, from it's position, open-bracket or open-parenthesis. This precedence ONLY applies within the brackets/parenthesis containing it
  2. ^ Assignment operators promote ALL operators to the right until the first un-bracketed/praenthesized separator, unmatched close bracket or close parenthesis, or semicolon. This precedence ONLY applies within the brackets/parenthesis containing it
  3. ^ There is no Short Circuiting of Logical Operators in LSL, both operands will be evaluated regardless.

Logical Operators

Logical Operators are operators those result is either TRUE or FAlSE.

  • insert truth tables

Bitwise Operators

Bitwise Operators are similar to Logical Operators, but act on all bits of an integer simultaneously as if they were each a Boolean value.

  • flesh this out

Pages in category "LSL Operators"

This category contains only the following page.