MetaSL specification 1.2.2
14 March 2011

MetaSL operators

Operators in MetaSL consist of the typical characters used for arithmetic operations (like “+” for addition) as well as those derived from the syntax used in object-oriented languages (the “.” character for member selection and “::” for scope resolution). The MetaSL operator set is listed below in three ways:

  1. Grouped by category
  2. Ordered by name
  3. Ordered by operator precedence

Symbols used in the tables

Operators listed by category

These divisions of the MetaSL operators are not part of their formal definition, but are presented here as one way of organizing them based on their use.

Arithmetic operators

E unary minus
+ E unary plus
E * E multiply
E / E divide
E % E modulo
E + E add
E E subtract

Boolean operators

! E logical not
uniform E uniformity test
E < E less than
E <= E less than or equal
E > E greater than
E >= E greater than or equal
E == E equal
E != E not equal
E && E logical and
E || E logical or
E ? E : E conditional expression

Set operators

~ E set complement
E & E set intersection
E ^ E symmetric difference
E | E set union
E in E set membership

Binary assignment operators

L = E simple assignment
L *= E multiply and assign
L /= E divide and assign
L %= E modulo and assign
L += E add and assign
L -= E subtract and assign
L &= E set intersection and assign
L ^= E symmetric difference and assign
L |= E set union and assign

Increment/decrement assignment operators

L ++ postfix increment
L postfix decrement
++ L prefix increment
L prefix decrement

Name specification operators

I :: I scope resolution
I :: T scope resolution
:: I global scope resolution
:: T global scope resolution
E . I member selection
E [ E ] subscripting

Procedural operators

I ( E ) function call
T ( E ) value construction

Execution order operators

E , E sequencing

Operators listed by name

All MetaSL operators are listed here by alphabetical order of their names.

Name Syntax
add E + E
add and assign L += E
conditional expression E ? E : E
divide E / E
divide and assign L /= E
equal E == E
function call I ( E )
global scope resolution :: I
global scope resolution :: T
greater than E > E
greater than or equal E >= E
less than E < E
less than or equal E <= E
logical and E && E
logical not ! E
logical or E || E
member selection E . I
modulo E % E
modulo and assign L %= E
multiply E * E
multiply and assign L *= E
not equal E != E
postfix decrement L
postfix increment L ++
prefix decrement L
prefix increment ++ L
scope resolution I :: I
scope resolution I :: T
sequencing E , E
set complement ~ E
set intersection E & E
set intersection and assign L &= E
set membership E in E
set union E E
simple assignment L = E
subscripting E [ E ]
subtract E E
subtract and assign L -= E
symmetric difference E ^ E
symmetric difference and assign L ^= E
unary minus E
unary plus + E
uniformity test uniform E
value construction T ( E )

Operators listed in order of precedence

In expressions that contain multiple operators, the order in which the operations are performed may affect the value of the result. For example, in the expression 3+2*5, is the value 25 (the result of multiplying 5 and 5) or is the value 13 (by adding 3 and 10)? The precedence of an operator defines the order of calculation with respect to other operators, that is, which operations precede other operations. In the table below, the precedence is listed in the third column; higher numbers define higher precedence. For example, the precedence for the multiply operator is 9 but the precedence for the addition operator is 8. Therefore, the expression 3+2*5 is 13, since multiplication is performed before addition. To override the precedence rules, parentheses can be used to group operations in an expression; the value of (3+2)*5 is 25.

Though the precedence of an operator is always used to resolve an expression that might otherwise be ambiguous, it is often best to include parentheses even when they are not strictly necessary. There is no performance penalty in the use of parentheses in an expression and its meaning should become clearer to the reader.

Syntax Name Precedence
I :: I scope resolution 16
I :: T scope resolution  
:: I global scope resolution  
:: T global scope resolution  
E . I member selection 15
E [ E ] subscripting  
I ( E ) function call  
T ( E ) value construction  
L ++ postfix increment  
L postfix decrement  
++ L prefix increment 14
L prefix decrement  
! E logical not  
E unary minus  
+ E unary plus  
~ E set complement  
uniform E uniformity test  
E * E multiply 13
E / E divide  
E % E modulo  
E + E add 12
E E subtract  
E < E less than 11
E <= E less than or equal  
E > E greater than  
E >= E greater than or equal  
E == E equal 10
E != E not equal  
E & E set intersection 9
E ^ E symmetric difference 8
E | E set union 7
E in E set membership 6
E && E logical and 5
E || E logical or 4
E ? E : E conditional expression 3
L = E simple assignment 2
L *= E multiply and assign  
L /= E divide and assign  
L %= E modulo and assign  
L += E add and assign  
L -= E subtract and assign  
L &= E set intersection and assign  
L ^= E symmetric difference and assign  
L |= E set union and assign  
E , E sequencing 1


© 2011 NVIDIA ARC GmbH. All rights reserved.