Simkin Expressions

Simkin supports the following expression types:

TypeDescriptionExample
literala literal value of one of the built-in data types"Simon", 100
selfa reference to the object owning the methodanotherObject.register(self)
nullan object meaning "nothing"if (node=null)
identifierthis is the name of a variable or method, see below for scoping rulesMyVariable
indirectionyou can prepend the identifier with @ to provide indirection@MyVariable
attributethis accesses an attribute in another object.
note: this is not supported for TreeNode objects
Account:Balance
fieldthis accesses a field or method in another object, or a sub-item within a fieldAccount.getPerson().Surname
self method callcalling a method on the current object and using the return valuesendMessage(message)
subexpressionfor grouping expressions and enforcing precedence(4+1)+5
Logical Operators
notnegates an expressionnot Overdrawn
andlogical andOverdrawn and WithinRedZone
orlogical orDepositAccount or CurrentAccount
Relational Operators
equalityequality testName="Simon"
inequalityinequality testName!="Simon"
less thaninteger/float less thana lt b or a < b
less than or equal tointeger/float less than or equal toa le b or a <= b
greater thaninteger/float greater thana gt b or a > b
greater than or equal tointeger/float greater than or equal toa ge b or a >= b
Arithmetic Operators
Note: Arithmetic operations are performed using floating point numbers, unless both values are integer.
For example:
1 + 2 = 3
1 / 2 = 0
"1" + "2" = 3.0
1.0 / 2 = 0.5
subtractinteger/float subtract12 - 1
addinteger/float addition12 + 1
minusinteger/float inversion- 1
timesinteger/float multiplication12 * 1
divideinteger/float division12 / 1
modulusinteger/float modulus12 % 1
String Operators
concatenationadding two strings together"First Name " # " Surname" or "First Name " & " Surname"
Array Operators
array indexfor accessing child objects (indices start from 0)a=f[6]