How to set a global value during execution of a predicate

While Jan W. will be able to give an exact answer, in the mean time I will suggest that if you search the source code for SWI-Prolog on GitHub you will find a few places where meta-interpreters are being used, e.g. IIRC the trace and debug predicates. As I don’t have exact working knowledge of them, I suspect that some of the corner cases might be handled with C code.

Also there is a place holder for a Wiki on Meta-interpreters on this site, the part of value is the related discussion topic which has some information.

Also some of the SWI-Prolog packs use meta-interpreters but I don’t recall which.

HTH


EDIT

Another place to look is in other GitHub repositories with Prolog code. While there are hundreds of such repositories, the better ones are noted here.

1 Like