# Built-In Preprocessor for context arguments

**URL:** <https://swi-prolog.discourse.group/t/built-in-preprocessor-for-context-arguments/5423>\
**Category:** Discussion\
**Created:** [May 24, 2022, 4:06am UTC](https://swi-prolog.discourse.group/t/built-in-preprocessor-for-context-arguments/5423 "2022-05-24T04:06:00Z")\
**Posts on this page:** 1\
**Showing post:** 23

<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:** [May 26, 2022, 6:29pm UTC](https://swi-prolog.discourse.group/t/built-in-preprocessor-for-context-arguments/5423/23 "2022-05-26T18:29:03Z")

</div>

It’s easy to add a “context” parameter using [package(edcg)](https://www.swi-prolog.org/pack/list?p=edcg):

```prolog
:- use_module(library(edcg)).
:- multifile edcg:pass_info/1.

edcg:pass_info(context).
edcg:pred_info(my_pred, 2, [context]).

my_pred(X, Y) -->>
    Context/context, % Unify Context with the `context` passed argument
    do_something(X, Y, Context.some_field).

```

This expands `my_pred/2` into `my_pred/3`:

```prolog
my_pred(X, Y, Context) :-
    do_something(X, Y, Context.some_field).

```

---

_[View the full topic](https://swi-prolog.discourse.group/t/built-in-preprocessor-for-context-arguments/5423)._
