I am calling a SWI Prolog engine from a C++ dll and I would like to be able to access all asserted/dynamic predicates (similar to what listing normally does).
In GNU Prolog I would call the dynamic/1 predicate with a Variable and Prolog would unify it with all dynamic predicate indicators. In the next step I would call these predicates with variables and get a complete list.
Unfortunately I can’t do that in SWI Prolog (ERROR: Arguments are not sufficiently instantiated).
Is there another way?
Why not just roll your own, for example:
Calling this backtracks to bind instances of predicates with head
Hin moduleMwith bodyBand clause referenceR. If all you wanted to retrieve are the names of the dynamic predicates, you could call this to retrieve the set of all bindings forH, or the functors thereof.Modify the predicate properties to those you’d prefer (or better yet, pass them in as arguments); the above definition will retrieve all user-defined dynamic predicates, which is what I’m guessing you’re after.