A.25.3 Predicates
- [semidet]include_macros(+M, +Macro, -Expanded)
- Include macros from another module. This predicate is a helper for
#import(File)
. It calls’$macro’/2 in M, but fails silently in case Macro is not defined in M as it may be defined in another imported macro file or further down in the current file. - [semidet]expand_macros(+Module, +TermIn, -TermOut, +PosIn, -PosOut)
- Perform macro expansion on TermIn with layout PosIn
to produce
TermOut with layout PosOut. The transformation is
performed if the current load context module is Module (see prolog_load_context/2).
This predicate is not intended for direct usage.
- [det]macro_position(-Position)
- True when Position is the position of the macro. Position
is a term
File:Line:LinePos
. If File is unknown it is unified with-
. If Line and/or LinePos are unknown they are unified with 0. This predicate can be used in the body of a macro definition to provide the source location. The example below defines#pp(Var)
to print a variable together with the variable name and source location.#define(pp(Var), print_message(debug, dump_var(Pos, Name, Var))) :- ( var_property(Var, name(Name)) -> true ; Name = 'Var' ), macro_position(Pos). :- multifile prolog:message//1. prolog:message(dump_var(Pos,Name,Var)) --> [ url(Pos), ': ', ansi([fg(magenta),bold], '~w', [Name]), ' = ', ansi(code, '~p', [Var]) ].