3.2 Pattern parameters

A pattern may have parameters, which may be data-items or virtual patterns.

Data-items may be normal objects or value objects. See the Section on objects and values for a description of the difference. See also the Section on Declarations.

Constant parameter

constant data-item describing a value object may be specified as follows using the keyword val.

foo(..., X: val T, ...): 
   ...

An actual patrameter must be specified as part of the generation of an instance of foo as in

foo(..., aT, ...)

In the body of foo, X is  constant and may not be assigned new values.

constant data-item describing a normal object may be specified as follows using the keyword obj:

foo(..., X: obj T, ...): 
   ...

Variable parameter

variable data-item describing a value object may be specified as follows using the keyword var.

foo(..., X: var T, ...): 
   ...

An actual patrameter must be specified as part of the generation of an instance of foo as in

foo(..., aT, ...)

In the body of foo, X is variable and may be assigned new values.

variable data-item describing a reference to a normal object may be specified as follows using the keyword ref:

foo(..., X: ref T, ...): 
   ...

Virtual patterns as parameters

A pattern may have a virtual pattern as a parameter and a binding of the virtual pattern must be supplied when an instance is generated.

with(V: var integer):do(body:< Action):
   ...

The parameter body is a virtual pattern qualified by he pattern Action. An invocation of %with%do% may have one of the following forms:

with (exp) :do (myAction)

where myAction is subpattern of Action. Or:

with (exp) :do 
   item1
   item2
   item3

where the argument following :do is an implicit subpattern of Action having the form:

Action
   item1
   item2
   item3

Example

An array pattern may be specified as follows:

array(range: var integer, elm:< Object): 
   ...

An instance of array may be declared as follows:

   A: = array(100,Integer)

Grammar

<Parameter> ::= <Declaration>

Se Section 4. Declarations.

Hello world