# How can a foreign language predicate also be a built-in predicate?

**URL:** <https://swi-prolog.discourse.group/t/how-can-a-foreign-language-predicate-also-be-a-built-in-predicate/961>\
**Category:** Help!\
**Created:** [July 16, 2019, 11:01am UTC](https://swi-prolog.discourse.group/t/how-can-a-foreign-language-predicate-also-be-a-built-in-predicate/961 "2019-07-16T11:01:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prodog](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@prodog](https://swi-prolog.discourse.group/u/prodog)\
**Post date:** [July 16, 2019, 11:01am UTC](https://swi-prolog.discourse.group/t/how-can-a-foreign-language-predicate-also-be-a-built-in-predicate/961/1 "2019-07-16T11:01:59Z")

</div>

> Binding an attributed variable schedules a goal to be executed at the first possible opportunity. In the current implementation the hooks are executed immediately after a successful unification of the clause-head or successful completion of a foreign language (built-in) predicate.

Do you know what this phrase “foreign language (built-in) predicate” means? I normally associate the term “foreign language” with an external module written in another programming language like “C/C++” and “built-in” as a part of the host language, which in this case is Prolog. How can a foreign language predicate also be a built-in predicate?

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [July 16, 2019, 11:17am UTC](https://swi-prolog.discourse.group/t/how-can-a-foreign-language-predicate-also-be-a-built-in-predicate/961/2 "2019-07-16T11:17:02Z")

</div>

> [@Can I use freeze/2 to detect a variable being instantiated, for debugging purposes?](https://swi-prolog.discourse.group/t/can-i-use-freeze-2-to-detect-a-variable-being-instantiated-for-debugging-purposes/958/4):
>
> How can a foreign language predicate also be a built-in predicate?

The low level parts of SWI-Prolog are written C and are thus foreign language. Many of the built-in predicates, e.g. unification (=), are low level and implemented in C and is thus a foreign language (built-in) predicate.

See: [Unification](https://github.com/SWI-Prolog/swipl-devel/blob/9ed270918b425d123be31c323366dc5e871f52cc/src/pl-prims.c#L207-L396)

There are many such predicates. In this [directory](https://github.com/SWI-Prolog/swipl-devel/tree/master/src) look for the files named `pl-<name>.c`

The keyword when searching the C code for such predicates is [PRED\_IMPL](https://github.com/SWI-Prolog/swipl-devel/search?q=PRED_IMPL&unscoped_q=PRED_IMPL)
