# Term\_expansion not applied

**URL:** <https://swi-prolog.discourse.group/t/term-expansion-not-applied/2731>\
**Category:** Help!\
**Tags:** how-to\
**Created:** [July 31, 2020, 9:29pm UTC](https://swi-prolog.discourse.group/t/term-expansion-not-applied/2731 "2020-07-31T21:29:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [August 1, 2020, 7:08am UTC](https://swi-prolog.discourse.group/t/term-expansion-not-applied/2731/2 "2020-08-01T07:08:56Z")

</div>

term\_expansion/2 is only called on the toplevel term. If you want to perform transformations inside the term you need to do so yourself. An intermediate step is provided by goal\_expansion/2, which is called for each goal term in a clause.

Also note that term\_expansion/2 is called only once per term, i.e., only the first answer of the expansion is used. goal\_expansion/2 is called on the goal until _fixed point_ is reached.

---

_[View the full topic](https://swi-prolog.discourse.group/t/term-expansion-not-applied/2731)._
