op(+Precedence, +Type, +Name)

declares Name to be an operator of the stated Type and Precedence.


Precedence integer
integer in the range 1-1200
Type one of [xfx,xfy,yfx,fx,fy,xf,yf]

Name atom
atom or a list of atoms.


Operators are a notational convenience to read and write Prolog terms. You can define new operators using op/3.

The Precedence of an operator is used to disambiguate the way terms are parsed. The general rule is that the operator with the highest precedence is the principal functor.

The Type of an operator decides the position of an operator and its associativity. In the atom that represents the type the character f represents the position of the operator. For example, a type fx says that the operator is a prefix operator. The character y indicates that the operator is associative in that direction. For example, an operator of type xfy is a right-associative, infix operator.

To cancel the operator properties of Name (if any) set Precedence to 0.

For more details, see ref-syn-ops


Precedence, Type or Name is a variable
Precedence is not an integer or Type is not an integer or Name is not an atom
Precedence is not in the range 1-1200

See Also

current_op/3 ref-syn-ops