# term\_expansion(module\_x:predicate(\_X), true) -- doesnt expand if included in module\_y

**URL:** <https://swi-prolog.discourse.group/t/term-expansion-module-x-predicate-x-true-doesnt-expand-if-included-in-module-y/3681>\
**Category:** Predicate\
**Created:** [March 3, 2021, 2:48pm UTC](https://swi-prolog.discourse.group/t/term-expansion-module-x-predicate-x-true-doesnt-expand-if-included-in-module-y/3681 "2021-03-03T14:48:10Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [March 4, 2021, 7:53am UTC](https://swi-prolog.discourse.group/t/term-expansion-module-x-predicate-x-true-doesnt-expand-if-included-in-module-y/3681/3 "2021-03-04T07:53:02Z")

</div>

term\_expansion/2 simply processes the output of read/1. Modules are not involved, except for which term\_expansion/2 rules are visible and the order in which they are handled. First it calls term\_expansion/2 in the module being loaded. The result is passed to user:term\_expansion/2 and the result thereof to system:term\_expansion/0. Next DCG translation and finally (dict) function expansion is done. The final output is passed to the backend compiler.

The predicate prolog\_load\_context/2 can be useful to examine the context in which the expansion takes place.

---

_[View the full topic](https://swi-prolog.discourse.group/t/term-expansion-module-x-predicate-x-true-doesnt-expand-if-included-in-module-y/3681)._
