term_expansion/2 hook


:- multifile term_expansion/2.

term_expansion(+Term1, -Term2)

The user may override the standard transformations to be done by expand_term/2 by defining clauses for term_expansion/2.


Term1 term

Term2 term


expand_term/2 calls term_expansion/2 first; if it succeeds, the standard grammar rule expansion is not tried.

expand_term/2 always calls term_expansion/2 in module user. Therefore, to be visible to expand_term/2, term_expansion/2 must either be defined in or imported into module user. Alternatively, you may define it in any module by using module prefixing; refer to ref-mod-vis.

This hook predicate may now return a list of terms rather than a single term. Each of the terms in the list is then treated as a separate clause.


See Also

expand_term/2, -->/2, phrase/[2,3], 'C', prolog_load_context/2. ref-gru