2.3 Compile time variables

In MacPas mode, compile time variables can be defined. They are distinct from symbols in that they have a value, and they are distinct from macros, in that they cannot be used to replace portions of the source text with their value. Their behaviour is compatible with compile time variables found in popular pascal compilers for Macintosh.

A compile time variable is defined like this:

{$SETC  ident:= expression}

The expression is a so-called compile time expression, which is evaluated once, at the point where the {$SETC } directve is encountered in the source. The resulting value is then assigned to the compile time variable.

A second {$SETC } directive for the same variable overwrites the previous value.

Contrary to macros and symbols, compile time variables defined in the Interface part of a unit are exported. This means their value will be available in units which uses the unit in which the variable is defined. This requires that both units are compiled in macpas mode.

The big difference between macros and compile time variables is that the former is a pure text substitution mechanism (much like in C), where the latter resemble normal programming language variables, but they are available to the compiler only.

In mode MacPas, compile time variables are always enabled.