Compiler Modes

## 6.3 Compiler Modes

The compiler has several modes of operation, each mode generating code with different properties. The operating mode is controlled by a set of global flags, which may be modified at any time, even during the compilation so that a part of the program is compiled in a different mode. These flags and the associated modes are listed below.

  debug_compile When this flag is on, the compiler generates code which can be traced with the debugger. To generate optimised (untraceable) code, this flag must be switched off. This can also be achieved by the use of nodebug compiler pragma in the program:

  >     :- pragma(nodebug).

  occur_check When this flag is on, the compiled code will perform the occur check if necessary. This means that every time a variable will be unified with a compound term that might already contain a reference to this variable, the compound term will be scanned for this occurrence and if it is found, the unification fails. In this way, the creation of infinite (cyclic) terms is impossible and thus the behaviour of the system is closer to the first order logic theory. Unifications with the occur check may sometimes be very slow, and most Prolog programs do not need it, because no cyclic terms are created. Note that this flag must be set both at compile time and at runtime in order to actually perform the checks. In particular, as ECLiPSe built-ins are compiled without this flag set, the builtins will not perform the check.
  variable_names ECLiPSe can remember the source variable names of the input variables. When this flag is on, the compiled predicates will keep the names of the source variables and will display them whenever the variables are printed. In this case the usage of the global stack and code space is slightly higher (to store the name), and the efficiency of the code is marginally lower. Setting this flag to check_singletons has the same effect as on, but additionally, the compiler will issue warnings about variables which occur only once in a clause and whose names do not start with an underscore character.
  all_dynamic When this flag is on, all procedures are compiled as dynamic ones (and there is no equivalent static/1 declaration). It can be used to port programs from older interpreters which rely heavily on the fact that all predicates in these interpreters were dynamic. Another possible use is to switch it on at the beginning of a file that contains many dynamic predicates and switch it off at its end.
  macro_expansion This is in fact a parser flag, is enables or disables the macro transformation (see Chapter 12) for the input source.
  goal_expansion Specifies whether to apply goal-macros or not (see Chapter 12).