#define
The booleans false and true are predefined. The way to define
symbols (that is the traditional name of those identifiers) consists
in using the #define directive, followed by the symbol, like so:
This opens the possibility to use Boolean expressions made of
trueandfalsealready mentioned;||for the disjunction ("or");&&for the conjunction ("and");==for equality;!=for inequality;!for negation;(and)around expressions to specify priorities.
Directives are processed in sequence in the input file. This
preprocessor, like that of C#, allows us to undefine a symbol,
that is, giving it the Boolean value false, like so:
The result is
Note: If you wish to redefine a symbol, you must undefine it first.
When we want to write a cascade of conditionals, the preprocessor
enables a shortcut by means of the #elif directive, like so:
Basically, a #elif directive is equivalent to #else followed by
#if, but we only need to close with only one #endif.
The rationale for using conditional directives in LIGO is to enable in a single smart contract several versions of a standard.
A real life example could be Dexter. It provides another interesting use of a conditional directive, where a record type depends on the version of the standard.