SEL Operators – Reference

SEL follows the Perl operator definitions for both usage and precedence. Associativity however may not be accurately emulated (I’m not that smart) *edit* I think I have now accurately executed correct associativity. Following is a list of precedence of all the operators usable in SEL, from Highest precedence to Lowest. Note that some operators share precedence ranking.

Precedence |
Operator |
Description |
Associativity |
---|---|---|---|

1 | Parenthesis | As with standard mathematics, anything in (parenthesis) takes precedence over everything else. If you aren’t 100% sure about the order your expression will be evaluated, use them! | Left |

2 | ** | Exponentiation, e.g. 2**8 is 2 to the power of 8 | Right |

3 | + (unary) | The plus sign used in an unary context to denote a number is positive, e.g. $x = +5 | Right |

3 | – (unary) | The minus sign used in an unary context to denote a number is negative, e.g. $x = -5 | Right |

3 | ! | The Logical ‘not’ operator – if an element evaluates to 0 or null/undefined, applying ! to it will make it equal logical true, or 1. The ! applied to anything that does NOT evaluate to logical 0 or null/undefined (e.g. ANY positive or negative number) , will result in logical false, or 0 | Right |

4 | * | Multiplication, used as you would expect, e.g. $x = 5 * 3 | Left |

4 | / | Division, e.g. $x = 24 / 6 | Left |

4 | % | Modulus – returns the ‘remainder’ in a whole number division operator, e.g. 7 % 2 = 1 (7 divided by 2 is 3 and the remainder is 1), so $x = 7 % 2 would assign 1 to $x | Left |

5 | + (binary) | The ‘plus’ as you may be expecting to use it. The denotation (binary) simply means it operates on 2 numbers. e.g. $x = 5 + 7 | Left |

5 | – (binary) | The ‘minus’ as you may be expecting to use it. The denotation (binary) simply means it operates on 2 numbers. e.g. $x = 12 – 7 | Left |

5 | . | The . (dot) concatenate operator, forms a single string from two scalar items (strings or numbers), e.g. 123.”456″ will form the single string “123456”. Variables may be used as long as they hold a scalar element | Left |

6 | < | The ‘less-than’ comparison operator. Returns a logical true or false (1 or 0), e.g. 5 <10 returns true. Very useful for ‘IF’ SEL statements and ABML tags | Left |

6 | > | The ‘greater-than’ comparison operator. Returns a logical true or false (1 or 0), e.g. 10 > 8 returns true. Very useful for ‘IF’ SEL statements and ABML tags | Left |

6 | >= | The ‘greater-than-or-equal-to’ comparison operator. Returns a logical true or false (1 or 0), e.g. 10 >= 8 returns true. Very useful for ‘IF’ SEL statements and ABML tags | Left |

6 | <= | The ‘less-than-or-equal-to’ comparison operator. Returns a logical true or false (1 or 0), e.g. 5 <= 10 returns true. Very useful for ‘IF’ SEL statements and ABML tags | Left |

7 | == | The ‘equal-to’ comparison operator. Returns a logical true or false (1 or 0), e.g. 23==23 returns true. Very useful for ‘IF’ SEL statements and ABML tags. Use on NUMERIC values | Left |

7 | != | The ‘NOT-equal-to’ comparison operator. Returns a logical true or false (1 or 0), e.g. 12!=23 returns true. Very useful for ‘IF’ SEL statements and ABML tags. Use on NUMERIC values | Left |

7 | eq | The alphabetic ‘equal-to’ comparison operator. Returns a logical true or false (1 or 0), e.g. ‘hello’ eq ‘hello’ returns true as does 23 eq 23. Very useful for ‘IF’ SEL statements and ABML tags. Use on WORD/Letter values. Case sensitive, ‘HELLO’ eq ‘hello’ returns false. | Left |

7 | ne | The alphabetic ‘NOT-equal-to’ comparison operator. Returns a logical true or false (1 or 0), e.g. ‘HELLO’ ne ‘goodbye’ returns true as does 23 ne 12. Very useful for ‘IF’ SEL statements and ABML tags. Use on WORD/Letter values. Case sensitive ‘HELLO’ ne ‘hello’ returns true. | Left |

7 | ieq | Case insensitive version of the ‘eq’ operator, ‘HELLO’ ieq ‘hello’ returns true. | Left |

7 | ine | Case insensitive version of the ‘ne’ operator, ”HELLO’ ine ‘hello’ returns false. | Left |

8 | && | Logical ‘and’ statement. If both statements on the left and right evaluate to Logical true then returns true, otherwise returns logical false, e.g. (6==6) && (3!=5) returns true. | Left |

9 | || | Logical ‘OR’ statement. If either of the statements to the left and right evaluate to logical true then returns true. It will only return false if both statements evaluate to false. e.g. (5==3) || (10==10) returns true | Left |

10 | = | Assignment operator. Used to assign values to variables and list variables, e.g. $x=5. Attempting to assign a value to a ‘constant’ value will cause an error, e.g. 5=5 will result in an error. The assignment operation itself returns the variable that was assigned *to*, e.g. $health=5 will return the variable $health which will now hold the value 5 | Right |

11 | , | The comma, used to seperate list values, e.g. $amp;mylist = (1,2,3,4,5), or &myfunction($param1, $param2) | Left |

12 | not | The Logical ‘not’ operator – if an element evaluates to 0 or null/undefined, applying ‘not’ to it will make it equal logical true, or 1, e.g. ‘not (5 > 3)’ evaluates to true. The ‘not’ applied to anything that does NOT evaluate to logical 0 or null/undefined (e.g. ANY positive or negative number) , will result in logical false, or 0. e.g. ‘not (5==5)’ evaluates to false. The reasons there are two versions, ‘not’ and ‘!’ is technical but has been included for Perl similarities | Right |

13 | and | Logical ‘and’ statement. If both statements on the left and right evaluate to Logical true then returns true, otherwise returns logical false, e.g. (6==6) and (3!=5) returns true. The reasons there are two versions, ‘and’ and ‘&&’ is technical but has been included for Perl similarities | Left |

14 | or | Logical ‘or’ statement. If either of the statements to the left and right evaluate to logical true then returns true. It will only return false if both statements evaluate to false. e.g. (5==3) or (10==10) returns true. The reasons there are two versions, ‘or’ and ‘||’ is technical but has been included for Perl similarities | Left |

14 | xor | Logical ‘exclusive-or’ statement. If one of the statements to the left or right evaluate to logical true, and the other to false it returns true. It returns false if both statements evaluate to false, or both statements evaluate to true. e.g. (5==3) xor (10==10) returns true, but unlike normal ‘or’, this: (5==5) xor (10==10 evaluates false). | Left |

Notes:

Short Circuit evaluation

Although the perl forms of ‘and’ and ‘or’ are included, SEL at this time DOES NOT short circuit evaluate (although it may one day). Do not use these operators expecting them to work in the way you may be used to using them in perl, e.g. ‘&myfunction or &anotherfunc’ will execute both functions even if &myfunction returns true.