[ Obsolete | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]

# global_op(+Precedence, +Associativity, ++Name)

Defines the global operator(s) in Name to have precedence Precedence and associativity Associativity. If Precedence is 0 then the operator definition is removed.

Precedence
  Integer
Associativity
  Atom
Name
  Atom or List of atoms

### This built-in predicate is obsolete!

## Description

Defines Name as an operator of precedence Precedence and associativity Associativity. Name may be a single operator or a list of operators, in which each is given the specified precedence and associativity.

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            postfix

x 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.

### Modes and Determinism

- global_op(+, +, ++) is det

### Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

### Exceptions

(4) instantiation fault
  Any of the input arguments is uninstantiated.
(5) type error
  Precedence is not an integer.
(5) type error
  Name is not an atom or list of atoms.
(6) out of range
  Precedence is not in range 0 to 1200.
(6) out of range
  Associativity is not xf, xfx, fy etc.
(43) multiple definition postfix/infix
  Multiple definition of postfix and infix for Name.

## Examples

    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)

## See Also

current_op / 3, op / 3