ProLog User Defined OperaTors Uv KLasT Ops Uv LisPLog

ISO ProLog: op/3 and current_op/3

These predicates allow the operator table to be altered or inspected.
op(Priority, Op_Specifier, Operator) is true, with the side effect that

if Priority is 0 then Operator is removed from the operator table, else
Operator is added to the Operator table, with priority (lower binds tighter) Priority and associativity determined by Op_Specifier according to the rules:
Specifier Type Associativity
fx prefix no
fy prefix yes
xf postfix no
yf postfix yes
xfx infix no
yfx infix left
xfy infix right
It is forbidden to alter the priority or type of ','. It is forbidden to have an infix and a postfix operator with the same name, or two operators with the same class and name.

The initial operator table is given by

Priority Specifier Operator(s)
1200 xfx :- —>
1200 fx :- ?-
1100 xfy ;
1050 xfy ->
1000 xfy ','
900 fy \+
700 xfx = \=
700 xfx == \== @< @=< @> @>=
700 xfx =..
700 xfx is =:= =\= < =< > >=
500 yfx + - /\ \/
400 yfx * / // rem mod « »
200 xfx **
200 xfy ^
200 fy - Template:op(+integer,+operator_specifier, @atom_or_atom_list)

Errors:

Priority is a variable — instantiation_error
Op_Specifier is a variable — instantiation_error
Operator is a partial list or a list with an element E which is a variable — instantiation_error
Priority is neither a variable nor an integer — type_error(integer, Priority)
Op_Specifier is neither a variable nor an atom — type_error(atom, Op_specifier)
Operator is neither a partial list nor a list nor an atom — type_error(list, Operator)
An element E of the Operator list is not an atom — type_error(atom, E)
Priority is not between 0 and 1200 inclusive — domain_error(operator_priority, Priority)
Op_specifier is not a valid operator specifier — domain_error(operator_specifier, Op_specifier)
Operator is ',' — permission_error(modify, operator, ',')
An element of the Operator list is ',' — permission_error(modify, operator, ',')
Op_specifierOperator would violate the prohibitions on multiple types — permission_error(create, operator, Operator)
current_op/3
current_op(Priority, Op_specifier, Operator) is true if and only if Operator is an operator with properties given by Op_specifier and Priority
Template:current_op(?integer, ?operator_specifier, ?atom)

Errors:

Priority is neither a variable nor an operator priority — domain_error(operator_priority, Priority)
Op_specifier is neither a variable nor an operator specifier — domain_error(operator_specifier, Op_specifier)
Operator is neither a variable nor an atom — type_error(atom, Operator)
char_conversion/2 and current_char_conversion/2
char_conversion(In_char, Out_char) is true, with the side effect of adding the pair (In_char, Out_char) to the character conversion table if In_char is not equal to Out_char and removing any pair (In_char, _) from the table if In_char is equal to Out_char .
When the flag char_conversion has the value true, the In_char will be replaced by Out_char when a term is read using read_term/3.

Template: char_conversion(+character, +character).

Errors:

In_char is a variable — instantiation_error
Out_char is a variable — instantiation_error
In_char is neither a variable nor a one character atom — representation_error(character)
Out_char is neither a variable nor a one character atom — representation_error(character)
current_char_conversion(In_char,Out_char) is true if and only if

In_char is not equal to Out_char, and
there is an entry in the character conversion table corresponding to the pair (In_char,Out_char)
Template: current_char_conversion(?character, ?character)

Errors:

In_char is neither a variable nor a one character atom — representation_error(character)
Out_char is neither a variable nor a one character atom — representation_error(character)