Noeud: Hilog terms, Noeud « Previous »: Enumeration variables, Noeud « Up »: Terms



Hilog terms

Hilog terms are an extension found in some Prolog evaluators (XSB among others) that gives a flavor of (pseudo) higher order very practical to build meta-predicates or closures.

The key idea is to consider that a sequence t (t1,..,tN) (with a <SPC> between the terms) is equivalent to apply(t,t1,...,tN).

The middle space can be removed when there is no ambiguity, for instance when t is an integer, a char, a variable, a compound term or a symbol declared as being hilog.

In case of ambiguity between an operator-based expression or an hilog expression, the operator-based expression will be chosen. For instance, - (a+b) represents the term -(a+b) and not apply(-,a+b).

One can force the hilog interpretation of a symbol by using the directive hilog/1.

The following program illustrate the use of hilog terms to build meta-predicates.

     closure(R)(X,Y) :- R(X,Y).
     closure(R)(X,Y) :- R(X,Z),closure(R)(Z,Y).
     
     :-hilog(r).
     r(a,b).
     r(b,c).