Logtalk reference manual
Built-in method: expand_goal/2
Contents > Reference Manual > Built-in Methods > expand_goal/2

## expand_goal/2

#### Description

    expand_goal(Goal, ExpandedGoal)

Expands a goal.

The expansion works as follows: if the first argument is a variable, then it is unified with the second argument; if the first argument is not a variable and clauses for the `goal_expansion/2` predicate are within scope, then this predicate is recursively called until a fixed-point is reached to provide an expansion that is then unified with the second argument; if the call to the `goal_expansion/2` predicate fails, the two arguments are unified.

Goal expansion is only performed by Logtalk at compile time (to expand the body of clauses and meta-directives read from a source file). This predicate can be used by the user to perform goal expansion at runtime (for example, before asserting a clause).

#### Template and modes

    expand_goal(?term, ?term)

#### Errors

`(none)`

#### Examples

`(none)`

#### See also

`expand_term/2`, `goal_expansion/2`, `term_expansion/2`