xf
, yf
,
xfx
, xfy
, yfx
, fy
or
fx
. The‘f
’indicates the position
of the functor, while
x
and y
indicate the position of the
arguments.‘y
’should be interpreted as “on
this position a term with precedence lower or equal to the precedence of
the functor should occur''. For‘x
’the
precedence of the argument must be strictly lower. The precedence of a
term is 0, unless its principal functor is an operator, in which case
the precedence is the precedence of this operator. A term enclosed in
parentheses ( ...
has precedence 0.
The predefined operators are shown in table 5. Operators can be redefined, unless prohibited by one of the limitations below. Applications must be careful with (re-)defining operators because changing operators may cause (other) files to be interpreted differently. Often this will lead to a syntax error. In other cases, text is read silently into a different term which may lead to subtle and difficult to track errors.
','
).|
) can only be (re-)defined as infix operator
with priority not less than 1001.
In SWI-Prolog, operators are local to a module (see also
section 6.9). Keeping
operators in modules and using controlled import/export of operators as
described with the module/2
directive keep the issues manageable. The module system
provides the operators from table
5 and these operators cannot be modified. Files that are loaded from
the SWI-Prolog directories resolve operators and predicates from this system
module rather than user
, which makes the semantics of the
library and development system modules independent of operator changes
to the user
module. See section
4.25 for details about the relation between operators and modules.
1200 | xfx | --> , :- , => |
1200 | fx | :- , ?- |
1150 | fx | dynamic, discontiguous, initialization, meta_predicate, module_transparent, multifile, public, thread_local, thread_initialization, volatile |
1105 | xfy | | |
1100 | xfy | ; |
1050 | xfy | -> , *-> |
1000 | xfy | , |
990 | xfx | := |
900 | fy | \+ |
700 | xfx | < , = , =.. , =@= , \=@= ,
=:= , =< , == ,
=\= , > , >= , @< , @=< , @> ,
@>= , \= , \== , as, is,
>:< , :< |
600 | xfy | : |
500 | yfx | + , - , /\ , \/ , xor |
500 | fx | ? |
400 | yfx | * , / , // , div, rdiv,
<< , >> , mod, rem |
200 | xfx | ** |
200 | xfy | ^ |
200 | fy | + , - , \ |
100 | yfx | . |
1 | fx | $ |