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

## term_expansion/2

#### Description

    term_expansion(Term, Expansion)

Defines an expansion for a term. This predicate, when defined, is automatically called by the `expand_term/2` method. Use of this predicate by the `expand_term/2` method may be restricted by changing its default public scope. The `term_expansion/2` clauses are only used by the `expand_term/2` method if they are within the scope of the sender. When that is not the case, the `expand_term/2` method only uses the default expansions. The `term_expansion/2` predicate may return a list of terms.

Term expansion may be also be applied when compiling source files by defining the object providing access to the `term_expansion/2` clauses as a hook object. Clauses for the `term_expansion/2` predicate defined within an object or a category are never used in the compilation of the object or the category itself. Moreover, terms wrapped using the `{}/1` compiler bypass control construct are not expanded and any expanded term wrapped in this control construct will not be further expanded.

Objects and categories implementing this predicate should declare that they implement the `expanding` protocol. This protocol implementation relation can be declared as either protected or private to restrict the scope of this predicate.

#### Template and modes

    term_expansion(+nonvar, -nonvar)
    term_expansion(+nonvar, -list(nonvar))

#### Errors

`(none)`

#### Examples

`term_expansion((:- license(default)), (:- license(gplv3))).`
`term_expansion(data(Millimeters), data(Meters)) :- Meters is Millimeters / 1000.`