Synonym declarations

In Elan the number of elements (``upper-bound'', ``cardinality'') in a row declaration must be given by a denotation, that is, it can not be dependent on the execution of the program. A row therefore has a statically fixed number of elements. (This is something of a nuisance but reflects the fact that rows in Elan do not serve like arrays in other languages. They are intended to be somewhat inflexible and primitive, and more convenient data types should be built upon them. In a beginners environment, their simplicity is an advantage).

Since this upper bound may have to appear in many places in a program, a mechanism is available which allows the naming of denotations. Such a synonym declaration looks like


\begin{elan}
LET max = 5
\end{elan}

which causes the identifier max to stand for the denotation 5 in suitable places. The identifier max can now be used as a denotation, e.g.:


\begin{elan}
ROW max INT VAR weight ;
FOR t FROM 1 UPTO max
REP
get ( weight [ t ] )
ENDREP
\end{elan}

In this example, the elements of the weight are read successively with the operation get. As shown in this example, rows and for-loops work together nicely; the use of synonyms assures that the same range of index values is used.