Conditional Compilation

Author(s): Jose F. Morales.

This package defines a serie of directives for conditional compilation that allow the inclusion or exclusion of code blocks (which may contain nested conditional directives) based on the truth value at compile time of special goals called conditions. The syntax for conditional directives is:

:- if(Cond1).
:- elif(Cond2).
:- else.
:- endif.

where elif(_) can appear zero or more times and the else part is optional. The valid conditions are:

  • calls to current_prolog_flag/2.
  • conjunctions, disjunctions, or negations of conditions.

The sentences in Block1 are included if the condition in Cond1 is satisfied, else Block2 is included if Cond2 is satisfied (and so on for each elif), and BlockN if no previous condition is satisfied.

Usage and interface

  • Library usage:
    The conditional compilation directives are enabled by including the condcomp package in the package list of a module or by means of an explicit :- use_package(condcomp)

Known bugs and planned improvements

  • This package implements a :- define(X) directive and defined(X) condition. However, the syntax and semantic of this feature has still to be decided. Do not use it.
  • Errors do not show line numbers