Next: Operators, Up: Marsyas Expression Syntax

- Basic Types
- Bool - can be true and false or shorthand $t and $f.
- Natural - a number without a decimal point.
- Real - floating point number (equivalent of a C double) can be written with leading or trailing decimal point - .123, 123., and 123.456.
- String - a string of characters delimeted by single quotes - 'hello' - which may contain newline \n or tab \t characters - '1\t2\t3\n'. Strings are also sequence types and can be modified using the sequence iterators.

- Type coercion
There are a few instances where type coercion may take place. Binary operators such as + require two values of the same type. Natural numbers are therefore promoted to reals in such a situation (1 + 1.0 := ((real)1) + 1.0). Real numbers are not converted to naturals in any case. For string concatenation using the + operator, any type concatenated to a string is converted to a string type (1+'2' := '12').

Type coercion also affects function parameters. For instance, the function Real.cos(real) when used as Real.cos(1) would result in a type error as 1 is interpreted to be a natural value. Instead the function call is converted to Real.cos((real)1).

Note that there is a performance penalty for coercion as slight as it may be.

- Type terms used in this document
- bool
- natural
- real
- string
- num_t := natural | real
- basic_t := natural | real | string | bool