Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

signature - Meaning of instantiation mode indicators in arguments of Prolog predicates

Looking at Prolog documentation, predicate signatures are sometimes written as following:

foo(:Bar, +Baz, -Qux, ?Mop)

What are :, +, - and ? for and how do I interpret them? Also, are these the only ones that exist or are there more of them?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Those prefix operators, in this context, represent instantiation modes, i.e. they tell you which arguments should be variables or instantiated when calling the predicate. They also tell you if an argument will be (possibly further) instantiated by the call. They can also be used to tell you that an argument is going to be meta-interpreted in some way by the predicate you're calling. Some of these instantiation modes are standard, other depend on the system. The most usual are:

- - the argument should be unbound (likely output argument)

+ - the argument should be bound (input argument)

? - the argument can be either bound or unbound

@ - the argument will not be further instantiated by the call

: - the argument will be meta-interpreted in some way (often ambiguous)

0 - the argument will be interpreted as goal and called as such

N - where N is natural number; the argument will be interpreted as a closure that will be composed with N additional arguments to construct a goal that will be called

Different systems provide other or different instantiation modes. For example, for stating that an argument should be ground when calling a predicate, or for stating that an argument should be a predicate indicator or that will be interpreted as a grammar rule body. You will need to refer to the documentation of the Prolog system you're using for the details.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...