Recent versions of SWI-Prolog include a pre-processing mechanism
called Prolog macros, implemented in
provides a convenient way for computing terms at compile time and
using them in code.
Macros are defined using special rules with
head terms. Then, when SWI-Prolog reads a term of the form
during compilation, it invokes the macro replacement rule and uses the
expanded term instead.
Sweep can replace macro invocations with their expansions. To expand a macro in your source code, use the following command:
Replace the Prolog macro invocation starting at point with its expansion.
You can call this command with point on the
# macro indicator
to expand the macro inline. To undo the expansion, use C-/
With Context Menu mode enabled, you can also expand macros by
right-clicking on the
# and selecting ‘Expand Macro’ from
the context menu. See Context Menu.