Code in Wrapl can be separated into modules. Each module consists of any number of variable and/or constant declarations, any of which can be exported allowing their use in other modules. To export a variable or constant, follow its declaration with an exclamation mark, !. To use such an exported variable/constant in another module, you can use an import declaration. For example:
In Wrapl, all identifiers must be declared. Variables are declared as VAR name;. This declares a new variable name in the current scope, which will be initialized to NIL. A variable can optionally be initialized when declared, VAR name <- value;.
Variables can be used at any point within the scope they are declared in, even before the actual declarations (i.e. foward declarations are unnecessary). However, the variable is only assigned its initial value at the actual declaration, prior to this it will have the value NIL. For example:
The alternative syntax VAR name(parameters) body; can be used to initialize a variable to hold a function. For example:
Constants can be declared in Wrapl using DEF instead of VAR. All constants must be given an initial value when declared, however a constant is assigned its initial value before any variables are initialized or any other expressions are evaluated in the same scope. For example: