Expressions
Expressions combine values using various operators to yield new values. For example, the very simple expression 1+2 uses the "+" operator to produce the value 3. SenseTalk provides a wide range of operators which serve many different needs.
The values used as components in expressions can be of many different types. They may be simple values, such as numbers or text strings (as described in Values), or they may be values that are the contents of containers (Containers). Still another type of value is one provided by a function
. A function is a source of value that retrieves information that may vary. SenseTalk provides many functions for a wide variety of purposes. For information on working with functions, see Functions.
SenseTalk is a "typeless" language, so containers can store any type of value: numbers, text, dates, lists, etc. Values are automatically converted as needed, so, for example, if you perform a mathematical operation on a text value, SenseTalk converts that value to a number internally. For converting internal values back into a text format, SenseTalk provides mechanisms that allow you to control the format used.
Precedence of Operators
Operators in complex expressions are evaluated in a specific order based on their precedence. The precedence of operators, from highest (those that are evaluated first) to lowest (those evaluated last) is as follows:
1st | ( ) (expressions enclosed in parentheses are evaluated first) |
2nd | (implicit concatenation—see below)not (logical not)- , negative (unary minus, or negation)+ , positive (unary plus)bitNot (bitwise not) |
3rd | ^ , to the power of (exponentiation)squared cubed % , percent ago hence , from now repeated , repeated up to a length of as with format , using format |
4th | * , times , multiplied by / , divided by div rem modulo , mod joined by split by rounded to rounded to nearest sorted |
5th | + , plus - , minus adding , adding the properties of replacing , replacing the properties of removing , removing the properties of , minus property retaining , retaining the properties of renaming , renaming the properties using |
6th | bitShift |
7th | & (concatenate strings)&& (concatenate strings with space)is a multiple of is evenly divisible by but at least , but no less than but at most , but no more than |
8th | &&& (concatenate list) |
9th | < , is less than , comes before > , is greater than , comes after <= , is less than or equal to , is at most >= , is greater than or equal to , is at least between contains is in is among is a is within |
10th | bitAnd (bitwise and) |
11th | bitXOr (bitwise exclusive or`) |
12th | bitOr (bitwise or) |
13th | = , is equal to , is <> , is not equal to , isn't begins with ends with matches |
14th | and and if (short-circuit and) |
15th | or or if (short-circuit or) |
When operators at the same level of precedence are used together in an expression, they are evaluated from left to right. In any case, parentheses can be used around a sub-expression to force that group to be evaluated before other parts of the expression (see Uses of Parentheses, below).
Implicit Concatenation
Implicit concatenation occurs when string literals, constants and certain predefined variables appear sequentially in an expression with no intervening operator. For example, this expression:
"Line 1" return "This is " "Line 2"