The operator is defined to be globally available, ie. visible in every module, unless hidden by a local operator.
Precedence is an integer in the range 0 to 1200. If the precedence is 0 the definition of the operator is removed.
Associativity must be one of the following atoms:
xfx infix xfy infix yfx infix fx prefix fy prefix xf postfix yf postfixx represents an argument whose precedence must be lower than that of the operator. y represents an argument whose precedence must be lower or equal to that of the operator.
Prefix, infix and postfix operators are independent of each other and may coexist. See the manual chapter on syntax about how ambiguities are resolved in this case.
Success: [eclipse]: global_op(100,fx,hello). % define prefix operator yes. [eclipse]: read(X). > hello david. % read using operator X = hello david yes. [eclipse]: global_op(200, xfy, -+-), global_op(300, fx, -+-). % multiple infix/prefix yes. [eclipse]: global_op(100,xfx,[a,b,c,d]). % define list of op's yes. [eclipse]: current_op(100,xfx,Y). % return defined op's Y = d More? (;) Y = a More? (;) Y = c More? (;) Y = b More? (;) % RETURN pressed yes. [eclipse]: global_op(300,xfy,?), global_op(300,yfx,:). yes. [eclipse]: display(a ? b ? c), display(a : b : c). ?(a, ?(b, c)) % xfy operator :(:(a, b), c) % yfx operator yes. [eclipse]: Error: global_op(X,fx,aaa). (Error 4) global_op(a,fx,aaa). (Error 5) global_op(100,xfx,1). (Error 5) global_op(100,abc,fred). (Error 6) global_op(100,xfx,aaa),global_op(100,xf,aaa). (Error 43)