Variable Definition

name{, name} : type-expression [:= expression]

A variable definition instruction introduces one or more names to the current name space, associates each of them with the specified type and initializes them either with the supplied value or with Undefined. When more than one name is defined by the same instruction, the initialization is performed as if the definition instruction were a multiple target assignment. There is no restriction on where a variable definition instruction may appear -- provided that a given name is used in a definition, once only, for each name space. For example, the following is illegal:
   i : Integer := 1
   i : String := `one'
However, variable definition instructions may occur inside loop bodies. In such cases, the name or names being defined are introduced into the name space only once (the first time the definition is encountered) but the initialization is performed again, every time the instruction is reached again. (Variables declared inside a for-loop are local to the loop.)

If a name is used before its defining instruction has been reached, its value is Undefined. If it is assigned to, before being defined, the assignment instruction implicitly defines a variable of type Entity. Explicitly defining a variable after it has been implicitly defined is treated as a redeclaration error.

It is not an error to use a name defined globally, before redefining it locally. It is recommended, however, to start all global variables with capital letters and all local variables with small letters. If this convention is followed, such potential errors will not arise.

Definition instructions are expected to disappear in future versions of Slim.


Herman Venter

This is Slim documentation as snarfed on 27 May 1999 by dB.