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])
].