Macros

SB-Prolog features a facility for the definition and expansion of macros that is fully compatible with the runtime system. Its basic mechanism is a simple partial evaluator. It is called by both consult and compile, so that macro expansion occurs independently of whether the code is interpreted or compiled (but not when asserted). Moreover, the macro definitions are retained as clauses at runtime, so that invocation of macros via call/1 at runtime (or from asserted clauses) does not pose a problem. This means, however, that if the same macro is used in many different files, it will be loaded more than once, thus leading to wasted space. This ought to be thought about and fixed.

The source for the macro expander is in the SB-Prolog system file
[3]modlib/src/$mac.P.



Subsections