A pattern is an abstraction mechanism that defines the structure of a (class of) objects. A pattern functions as a template, that when executed generates an object of the specified structure.

A pattern declaration has the form

<Signature>: <ObjectGenerator>

where <Signature> describes the name, arguments and return values of the pattern. <ObjectGenerator> describes an object.

The signature may have one of 4 forms: unary, functional, binary or keyword.

Unary patterns

A unary pattern, is a pattern that has no arguments and no return value is specified. By default the return value is a reference to this.



Functional patterns

A functional pattern, is a pattern that have a list of arguments specified in a functional style within brackets and separated by commas (','). A list of return values may be specified - the default return value is a reference to this.


Max(x: ? Integer, y: ? Integer) -> z: ? Integer:

Binary patterns

A binary pattern, is a pattern with one argument and a name consisting of a sequence of special symbols, like '+', '*', '$', etc


+ V: ? Integer -> res: ? Integer:

where '+' is the name of the pattern, V is the argument and res is the return value.

/&/ Q: ? T -> W: ? S:

where '/&/' is the name of the pattern, Q is the argument, and W is the return value.

The following reserved special symbols cannot be used in a binary pattern name: ':', ',', '.', '%', ...

Keyword patterns

A keyword pattern, is a pattern where the name is a list of keywords separating the arguments of the pattern:

%prefix arg1: ? T1 %sep1% arg2: ? T2 %sep2% arg3: ? T3 ... %sepn%

The name of the pattern is %prefix%sep1%%sep2%%...%sepn%


%put V: ? integer %at% pos: ? Integer: