4.7 Syntax Restrictions

Note carefully the following syntax restrictions, which serve to remove potential ambiguity associated with prefix operators.

  1. In a term written in standard syntax, the principal functor and its following `(' must not be separated by any intervening layout-text. Thus
              point (X,Y,Z)
         

    is invalid syntax.

  2. If the argument of a prefix operator starts with a `(', this `(' must be separated from the operator by at least one layout-char. Thus
              :-(p;q),r.
         

    (where `:-' is the prefix operator) is invalid syntax. The system would try to interpret it as the compound term:

                  ,
                 / \
               :-    r
                |
                ;
               / \
              p   q
         

    That is, it would take `:-' to be a functor of arity 1. However, since the arguments of a compound term are required to be expressions of precedence below 1000, this interpretation would fail as soon as the `;' (precedence 1100) was encountered.

    In contrast, the term:

              :- (p;q),r.
         

    is valid syntax and represents the following compound term:

                 :-
                  |
                  ,
                 / \
                ;   r
               / \
              p   q