Constants
There are three kinds of constant values in a SIMPOL program, string literals, numeric literals and intrinsic constants.
String literals can be delimited by either single or double quotes, but the ending delimiter must match the starting
delimiter. This allows single and double quotes to be used in strings without any special escape sequences, e.g.:
"Can't"
or 'Fred said "no"'
. Numeric literals can be specified in one of several bases
by starting them with a leading zero and then a base indicator letter, e.g.: 0d100
(decimal),
0xff
(hexadecimal), 0o377
(octal) or 0b11001101
(binary). If
no leading zero and base indicator are found then the number is assumed to be decimal. Intrinsic constants are identifiers
that have a single fixed value. The permitted constants are .nul
(the null value), .inf
(infinity), .true
(the boolean true value) and .false
(the boolean false value).
A function can return a value by specifying that value after the end function that terminates the function, for example:
function main() end function "The end of the program"
or
function main() string s s = "Hello world" end function s
If no return value is specified then the return value is the null constant, .nul
. A function can be called from
within an expression, and may take parameters in the normal way, for example the following program will have a final return
value of 15
:
function main() integer i i = 5 i = i + double(i) end function i function double(integer i) end function i+i