# What is meant by "meta-level" in logic programming?

**URL:** <https://swi-prolog.discourse.group/t/what-is-meant-by-meta-level-in-logic-programming/7717>\
**Category:** General\
**Created:** [August 22, 2024, 11:09am UTC](https://swi-prolog.discourse.group/t/what-is-meant-by-meta-level-in-logic-programming/7717 "2024-08-22T11:09:03Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [August 22, 2024, 8:31pm UTC](https://swi-prolog.discourse.group/t/what-is-meant-by-meta-level-in-logic-programming/7717/7 "2024-08-22T20:31:03Z")

</div>

> [@stassa.p](#):
>
> `call/n` is the quintessential “meta-predicate” and that makes sense since it’s basically a kind of … meta interpreter?

Yes, but `call/n` can be defined as a first-order thing (just add a corresponding `call/n` clause for every predicate in the program), so I don’t think of it as something special. Others might disagree.

> [@stassa.p](#):
>
> the “thunk” thing

“Thunk” is, I suppose an old-fashioned word for what is now called “closure” (although the definition of “closure” is somewhat variable, it seems) – basically, a pointer to code plus some environment. See also [delimited continuations](https://www.swi-prolog.org/pldoc/man?section=delcont), which I don’t fully understand.

So, it _might_ be useful to have something like `term_closure/2` or `term_callable/2` that maps between a term and something that can be called. Whether this would be more or less confusing than call/1, call/2, etc., I don’t know.

> [@stassa.p](#):
>
> `call/n` is the quintessential “meta-predicate” and that makes sense since it’s basically a kind of … meta interpreter?

If you have the following _code_:

```prolog
number_word(0, zero).
number_word(1, one).
number_word(2, two).
number_word(I, big) :- I > 2.

```

then there’s a _predicate_ `number_word/2` that has 4 clauses, and all of the clauses happen to have the syntax of a term (see: [homoiconicity](https://en.wikipedia.org/wiki/Homoiconicity)). There’s no intrinsic reason why this to be true – Picat, for example, does not represent its predicates in a form that is directly representable as terms. (Lisp is the canonical example of homoiconicity; but it has the opposite default from Prolog: everything is called unless specifically quoted (e.g., by the `QUOTE` special form)).

It’s convenient to have the same syntax for predicates and terms, for things like macro-expansion or program analysis (see clause/2) or for dynamically adding facts/rules (see assertz/1); but it also confuses beginners. (Does the similar thing in Lisp also confuse beginners?)

---

_[View the full topic](https://swi-prolog.discourse.group/t/what-is-meant-by-meta-level-in-logic-programming/7717)._
