Simkin supports the following expression types:
Type | Description | Example |
---|---|---|
literal | a literal value of one of the built-in data types | "Simon" , 100 |
self | a reference to the object owning the method | anotherObject.register(self) |
null | an object meaning "nothing" | if (node=null) |
identifier | this is the name of a variable or method, see below for scoping rules | MyVariable |
indirection | you can prepend the identifier with @ to provide indirection | @MyVariable |
attribute | this accesses an attribute in another object. note: this is not supported for TreeNode objects | Account:Balance |
field | this accesses a field or method in another object, or a sub-item within a field | Account.getPerson().Surname |
self method call | calling a method on the current object and using the return value | sendMessage(message) |
subexpression | for grouping expressions and enforcing precedence | (4+1)+5 |
Logical Operators | ||
not | negates an expression | not Overdrawn |
and | logical and | Overdrawn and WithinRedZone |
or | logical or | DepositAccount or CurrentAccount |
Relational Operators | ||
equality | equality test | Name="Simon" |
inequality | inequality test | Name!="Simon" |
less than | integer/float less than | a lt b or a < b |
less than or equal to | integer/float less than or equal to | a le b or a <= b |
greater than | integer/float greater than | a gt b or a > b |
greater than or equal to | integer/float greater than or equal to | a ge b or a >= b |
Arithmetic Operators
Note: Arithmetic operations are performed using floating point numbers, unless both values are integer. For example:
| ||
subtract | integer/float subtract | 12 - 1 |
add | integer/float addition | 12 + 1 |
minus | integer/float inversion | - 1 |
times | integer/float multiplication | 12 * 1 |
divide | integer/float division | 12 / 1 |
modulus | integer/float modulus | 12 % 1 |
String Operators | ||
concatenation | adding two strings together | "First Name " # " Surname" or "First Name " & " Surname" |
Array Operators | ||
array index | for accessing child objects (indices start from 0) | a=f[6] |