Next: Statements
Up: The ALLCOT syntax
Previous: Defining a category
A domain definition looks like
Identifier : Identifier Identifier DomainBody |
|
or like
Identifier : Identifier DomainBody |
|
where in each case
- the first
Identifier must be a new identifier,
- the second
Identifier must refer to an existing category,
- the third
Identifier, if present, must refer to an existing domain.
The inheritance mechanism will be discussed later.
The
DomainBody starts with an attrib-statement, that is
a statement of the form
and continues with a sequence of function definitions.
A function definition looks like
Identifier FormalParameterSequence : Type Statement |
|
or like
Identifier FormalParameterSequence : Type StatementSequence |
|
These function definitions must satisfy the category of the domain.
A sequence of formal parameters is a sequence of
declarations of the form
separated by commas.
The goal of the attrib-statement is to declare
the attributes of a value (or object) of the domain
(or class) being defined.
In the case of
- OddNumbers, each value has just
one attribute which is an Integer,
- Word, each value has two attributes:
a String called st and an Integer
called le representing the length of this String.
Note that attrib is also used as a private creator.
Public creators have to use attrib directly
or indirectly in order to initialize a new value.
Next: Statements
Up: The ALLCOT syntax
Previous: Defining a category
Marc Moreno Maza
2004-12-01