Syntropy Type view Object diagrams/mechanisms Statecharts Logic Value types Glossary

Value types

Syntax

Built-in types often come equipped with their own syntax for applying operations. For example, numbers can have infix binary operators such as +, , etc., and prefix unary operators such as and the square root symbol; Booleans have infix binary operators representing and, or, etc., and the prefix unary operator not. Each of these sets of operators has its own natural precedence for bracketing.

Our scheme for operator syntax allows operator signatures to be defined as prefix, infix or postfix using a positional notation. For example:

Only operators defined using the postfix dot notation may take additional parameters, as in Rectangle.contains(Point): Boolean. This notation is the same as that used for object navigation expressions and message-sending.

The following operator precedence rules apply, from highest to lowest, to all expressions (including those involving objects):

Parentheses ( ) may be used to override these rules, in the normal way. When operators of the same precedence appear unbracketed together, the left-most takes precedence.


Boolean

Literals

{true, false}

Type specification


Character

Literals

{ @a, @b, @c, ..., @A, @B, @C, ...} : characters are prefixed by @ signs.

Type specification

The only operation defined on characters is equality: @a=@a, etc.

Symbol

Literals

{ %symbol, ... } : symbols are prefixed by percent signs.

Type specification

The only operation defined on symbols is equality: %abc=%abc, etc.

Number

Literals

{1.0, 1.1, 123456789.987654321, ...} : arbitrary-precision rational numbers specified using decimal notation.

Note that {0, 1, 2, ...} are Integer literals, see below: Integer is a sub-type of Number, so these literals also denote Number values.

Note that Number values can also be denoted by dividing two Integer values, for example 22/7.

Type specification


Integer

Literals

{...,-2,-1,0,1,2,3...} : the normal integer numerals.

Type specification

Integer is a sub-type of Number. This means that an Integer value can be used wherever a Number value is expected. This has the following implications:


Integer sub-ranges

The syntax of sub-ranges of Integer is lower..upper, lower being the lower bound and upper the upper (e.g. 1..10).

String

Literals

{'hello world', ... } : strings are contained in single quotes. The empty string is denoted by ''.

Type specification


Comments, corrections to jdaniels@cix.co.uk