Next: , Previous: , Up: Top   [Index]

5 Variables

Variables are typed and named value holders.

Variables always hold values, even if none was assigned to them yet. With the notable exception of the intrinsic numerical types, that have random initial values, most other types have defined initial values. Variables of the intrinsic string type are ‘""’ (the empty string) upon declaration. Variables of most referable types indicate a newly created object.

See The Intrinsic Types.

Variables have valid aime identifier names, starting with ‘_’ or a letter and continuing with ‘_’ signs, letters and digits.

The value of any aime declared variable may be modified. The aime interpreter and the application embedding it may nonetheless define read only variables.

Variables are declared at the beginning of blocks, before any statement (the blocks syntax has sequences of declarations and statements enclosed by braces). The variables are available only in their own scope, the block in which they were declared.

The variables declaration syntax has the type name of the data variables can hold followed by the comma separated list of variable names and a semicolon.

    integer a, b1, c23, _d4;
    real _5e;
    text f6g7, h_i_8;
    cardinal _;
    file input, output;
    data data1, data2, data3;
    date current_date, tomorrow;

No two variables may have the same name and the same scope. aime keywords (‘if’, ‘while’ and alike) and type names may not be used for variable naming.

The data variables point is destroyed when the variables come out of scope if no other references to it exist.