Apart from the Bottom-Up declarations already described, Elan has Top-Down declarations for declaring objects. Every object in an Elan program has a name, a type, an access attribute (VAR or CONST) and (during execution) a value, which may be undefined. There are two forms of object-declaration:
(315,060) (000,050)object-declaration (000,030)(1,0)030100variable-declaration (1,0)030 (005,020)(20,20)[rt] (025,020)(20,20)[lb] (025,010)(1,0)005100constant-declaration (1,0)005 (135,020)(20,20)[rb] (155,020)(20,20)[lt]
A variable-declaration declares one or more objects (variables) with the access attribute VAR of one same type.
(315,090) (000,080)variable-declaration (000,060)(1,0)030060type-declarer (1,0)030040VAR (1,0)005 (165,050)(20,20)[r] (275,030)(20,20)[r] (275,040)(-1,0)060 (025,040)(1,0)18010, (025,030)(20,20)[l] (025,020)(1,0)005080variable-name (1,0)03010:: (1,0)030060expression (1,0)060 (115,010)(20,20)[rt] (135,010)(20,20)[lb] (135,000)(1,0)110 (245,010)(20,20)[rb] (265,010)(20,20)[lt]
The expression preceded by the curious sign :: is the initialization for the variable. Its value (or, if there is no initialization, an undefined value) is assigned to the variable-name.
A constant is an object with the access attribute CONST and always obtains a well defined value at its declaration.
(315,080) (000,070)constant-declaration (000,050)(1,0)030060type-declarer (1,0)030040CONST (1,0)005 (165,040)(20,20)[r] (275,020)(20,20)[r] (275,030)(-1,0)060 (025,030)(1,0)18010, (025,020)(20,20)[l] (025,010)(1,0)005080constant-name (1,0)03010:: (1,0)030060expression (1,0)060
A variable can obtain another value assignation, whereas a constant can not be assigned to. If so desired, the access attribute CONST may be left out, but this is not advised since it leads to degradation of syntactic error-detection. An object-declaration may very well occur in a repetition. Each time the declaration is executed, its initialization is executed anew.