A declaration is either a constant or variable data item, a singular object, or a virtual or non-virtual pattern.

Constant

A constant declaration has the form

name: = <ObjectGenerator>

where name is the name of the object and <ObjectGenerator> is an action that generates the object –the ObjectGenerator is executed when the constant is generated as part of the generation of the enclosing object.

A singular object is a constant data-item.

Examples

C1: = integer(7)
C2: = 7
C3: = Point(3,4 + y)
C4: = Record
C5: = Person("John Smith",21)

Variable

A variable declaration has the form

name: ? <ObjectGenerator> or <PatternName>

where name is the name of the object - name may refer different objects during the lifetime of the enclosing object.

If <ObjectGenerator> then an object is generated as the initial object that name refers.

If <PatternName>, then the initial value is NONE, which refers no object.

Examples

V1: ? integer --  or integer(0), integer()??
V2: ? integer(7) -- the initial value of V2 is 7
V3: ? Point(3,4) -- the initial value is an instance of Point(3,4)
V4: ? Record - initial value is none
V5: ? Person -- ditto

Note

A constant declaration like C: = integer(7) may syntactically be confused with an assignment of the form C := exp.   We may change the syntax of assignment to:

V <-  exp

Until this happen, it is necessary that there is at least one blank between ':' and '=' in a constant declaration.

For unary patterns there is an issue: let Person be a unary pattern:

C: = Person -- C should be a constant reference to an instance of Person,

V: ? Person -- Is V initially none or an instance of Person?

Alternatively we may use #Person to denote the name of a pattern, including #%put%at%, etc - this may also solve how we refer to names using %inner, %restart of %leave. Then

V: ? #Person -- is initially none
V: ? Person -- is initially an instance of Person

Another alternative may be to avoid none references all together - cf Hoare and others - for this to work we must make it easy to define none-like patterns for all patterns.