Get name of current predicate?

I’m using: SWI-Prolog version 8.0.2.

Is there a function you can use from the clause body of a predicate to find out the name of the predicate the clause body belongs to?

For example:

somepred :-
     get_current_predicate(CurrentPredName).

So CurrentPredName would be somepred in this example.

If there is such a function, what is its name and does it work within sandboxed code running in a PEngines instance?

See https://www.swi-prolog.org/pldoc/man?section=manipstack

1 Like

@prodog

I too am interested in how this is done; can you post a working example, thanks.