Logtalk reference manual
Built-in method: goal_expansion/2

goal_expansion/2

Description

goal_expansion(Goal, ExpandedGoal)

Defines an expansion for a goal. The first argument is the goal to be expanded. The expanded goal is returned in the second argument. This predicate is called recursively on the expanded goal until there are no changes. Thus, care must be taken to avoid compilation loops. This predicate, when defined, is automatically called by the expand_goal/2 method. Use of this predicate by the expand_goal/2 method may be restricted by using a scope directive for it. This predicate is called when compiling source files.

Goal expansion may be used either by calling the expand_goal/2 method explicitly or by using hook objects. Clauses for the goal_expansion/2 predicate defined within an object or a category are never used in the compilation of the object or the category itself.

Template and modes

goal_expansion(+callable, -callable)

Errors

(none)

Examples

goal_expansion(write(Term), (write_term(Term, []), nl)).