Next: , Previous: , Up: mpg-bpr   [Contents][Index]


11.3.150 ;/2   ISO

Synopsis

+P ; +Q

Disjunction: Succeeds if P succeeds or Q succeeds.

+P -> +Q ; +R

If P then Q else R, using first solution of P only.

Arguments

:P

callable, must be nonvar

:Q

callable, must be nonvar

:R

callable, must be nonvar

Description

These are normally regarded as part of the syntax of the language, but they are like a built-in predicate in that you can write call((P ; Q)) or call((P -> Q ; R)).

By default, the character ‘|’ (vertical bar) can be used as an alternative to the infix operator ‘;’. This equivalence does not hold when ‘|’ has been declared as an operator.

Using ‘|’ as an alternative to the infix operator ‘;’ is not recommended. A future version of the ISO Prolog standard is likely to define ‘|’ as an operator and with such an operator definition the ‘|’ will no longer be equivalent to ‘;’.

The operator precedences of the ‘;’ and ‘->’ are both greater than 1000, so that they dominate commas.

Cuts in P do not make sense, but are allowed, their scope being the goal P. The scope of cuts in Q and R extends to the containing clause.

Backtracking

For the if-then-else construct: if P succeeds and Q then fails, then backtracking into P does not occur. A cut in P does not make sense. ‘->’ acts like a cut except that its range is restricted to within the disjunction: it cuts away R and any choice points within P. ‘->’ may be thought of as a “local cut”.

Exceptions

Call errors (see ref-sem-exc).

See Also

ref-sem.



Send feedback on this subject.