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 <#1670#>synonym declaration<#1670#> looks like


#litout1740#

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


#litout1742#

In this example, the elements of the <#1678#>weight<#1678#> are read successively with the operation <#1679#>get<#1679#>. 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.

#./h02.tex# #./h03.tex#