spec

Software for Diffraction

2.4.3. - Variables



global name ...
Declares name to be a global symbol. A global symbol retains its value after each parsed program is executed. If name is used as an array name, each element of the array is global. By appending empty square brackets to name the type of the symbol can be forced to be an associative array, which may be useful if name is to be used as an argument to a macro function before its type has been established by usage.

unglobal name ...
Makes the global or constant symbol name no longer global.

constant name [=] expression
Declares name to be a constant, global symbol having the value given by expression. A constant symbol cannot be changed by assignment.

local name ...
Allows reuse of a preexisting name and gives the new instance of that name scope only within the statement block in which it is defined. The name may be that of a macro, in which case the macro definition is unavailable within the statement block. By appending empty square brackets to name the type of the symbol can be forced to be an associative array, which may be useful if name is to be used as an argument to a macro function before its type has been established by usage.

delete assoc-array[elem] ...
Removes the element elem of the associative array assoc-array.

syms [-v] [+|-BGLADNSIC] [pattern ...]
Lists spec's current variables. Without arguments, all the variables are listed, along with their memory consumption and type. With the -v flag, the variables are listed along with their values in a format that can be saved to a file and read back as commands. If arguments are given as pattern, only symbols matching the arguments are printed. Such arguments may contain the ? and * metacharacters.

In addition, the type of symbols listed can be controlled using the flags in the following table where a - flag prevents symbols with the given attribute from being listed and a + flag includes symbols with the given attribute in the list.
 B   Built-In 
 G   Global 
 L   Local 
 A   Associative array 
 D   Data array 
 N   Number type 
 S   String type 
 I   Immutable attribute 
 C   Constant attribute 



[[extern] shared] [type] array var[cols]
Declares a one-dimensional data array.

[[extern] shared] [type] array var[rows][cols]
Declares a two-dimensional data array.