Is there a meta_predicate tutorial?

Or it could be that I am missing something simple.

One of the problems I am having with Prolog is that sometimes a call needs to be made from one predicate in one module to a predicate in another module. From what I am gathering is that if sometimes the call can not be made is because Prolog does not know which module to use for the predicate. The better way to resolve this seems to be using meta_predicate/1. See: Using prolog_walk_code/1 to identify meta predicate calls?. In that the call is added at the binary level, but if you list out the source using listing/1 you might expect to see the added meta-predicate, but I don’t. The references talk about other ways to deal with the problem but some are clearly seen as being very wrong, i.e. hardcoding the module with the predicate.

Also if you read some of the references there is a big difference between a Goal and closure, still don’t get that one. Also there are more than one way to solve this problem as noted in “The Craft of Prolog” by Richard O’Keefe Section 6.13 Meta-programs and Object-Oriented Programming.

In trying to understand this, it makes one really have to understand the deeper happenings of the code with regards to calls between modules and history of what it has done to Prolog. It seems in the land of Prolog there was happiness, then modules where added and the world or Prolog shattered like broken glass. :frowning_face:

I have been purposefully avoiding mentioning my specific problem because I don’t want the discussion to focus on that particular problem and then still leave me with a large gap in my knowledge. Until today I would not have guessed that cut (!/0) and once/1 would be of consideration with these problems.