Next: Builtin domains
Up: Language extensions
Previous: Language extensions
The ALDOR solution is very elegant.
It is based on the following features
 In ALDOR, one can write
a function which returns a domain (or a category).
Moreover, such functions can take categories, domains or elements
among their arguments.
So, if T is a domain, one can create a function
Array such that Array(T) is a domain
whose elements are arrays of elements from T.
 In ALDOR, one can define a domain, a category or a function
in any scope.
Of course, we do not plan to implement such features in ALLCOT.
But we would like to create arrays of any type in any scope of the source program.
However, in order to make such arrays easy to translate into our intermediate language,
we can restrict to fixed size arrays.
For declaring a variable of an array type, let us modify the Typerules as follows.
Type 

% 
Type 

id 
Type 

Array ( id ,
ArithmeticExpression ) 
where, in the third rule, id is meant to be a type and
ArithmeticExpression is meant to be
a positive integer.
For initializing an array, we need to add a special form of
RightValue, such that
the
RightValuerules become
RightValue 

FunctionCall 
RightValue 

ArithmeticExpression 
RightValue 

BooleanExpression 
RightValue 

[
RightValueSequence ] 
RightValueSequence 

RightValue 
RightValueSequence 

RightValueSequence ,
RightValue 
Then, we need to read and overwrite an element in an array, which means accessing
an element in an array. This can be done exactly like in an
AttributeCall.
Therefore, the following program fragment becomes syntactically valid
x: Array(Integer, 3) := [2,3,6];
i: Integer := 2;
x.i := 5;
Observe that this solution for arrays is coherent for the philosophy of
ALLCOT and ALDOR.
In fact, the ALLCOT Array can be viewed as a builtin domain constructor.
Next: Builtin domains
Up: Language extensions
Previous: Language extensions
Marc Moreno Maza
20041201