f(a:-b,c) or f((a:-b),c) - How should compound args be parsed?



Hi -
According to the draft (D8) ISO standard 1993 (which is the only
standard I have been able to find on the web for free downloading),
arguments in a compound term or list should have precedence less than
the comma operator, ie 999 or lower, so that any expressions whose
precedence is greater than this should be enclosed in parentheses.

GNU Prolog 1.2.16 enforces this rule, so that f(a:-b, c) gives a syntax
exception since infix :- has precedence 1200.

However SWI-Prolog 5.4.7 allows argument expressions of greater
precedence, so I am wondering if this is because the actual ISO
standard has changed from the draft in this respect or if this is now
common in other prologs, since it is much more convenient. In effect
arguments are parsed as if the comma was not defined as an operator at
the top level of parsing (ie the comma cannot be the top level operator
of the arg expression).

A similar question arises in relation to the list syntax, also when '|'
is used as an operator ie in SWI Prolog:

2 ?- op(300, xfy, |).

Yes
3 ?- X = [a|b,c], X = [H|T].

X = [a| (b, c)]
H = a
T = b, c

so even though infix | is defined as an op, the op definition is
"hidden" at top level when parsing list syntax. Again from D8 1993 I
would have thought this would have been parsed as [(a|b),c] since a|b
only has precedence 300 and is thus an 'exp' (though I'm not
complaining I like the SWI ways above...)

Is this the same in other prologs?

Thanks, Brian.

.



Relevant Pages

  • Re: f(a:-b,c) or f((a:-b),c) - How should compound args be parsed?
    ... > the comma operator, ie 999 or lower, so that any expressions whose ... > precedence is greater than this should be enclosed in parentheses. ... > standard has changed from the draft in this respect or if this is now ... > is used as an operator ie in SWI Prolog: ...
    (comp.lang.prolog)
  • Re: Sequence points
    ... consecutive sequence points with respect to ordinary operations tracks ... follow operator precedence. ... determined, even before the standard, was inadequate based on my prior ... They are engaged in mail fraud, ...
    (comp.programming)
  • Re: compare a large number of variables
    ... There's a sequence point after ... evaluating the LHS of the comma operator. ... if the comma operator has higher precedence. ...
    (comp.lang.c)
  • Re: C/C++ Ambiguity in Order of Evaluation
    ... The order of evaluation of subexpressions is determined by the ... precedence and grouping of the operators. ... A reference manual that implements a language standard should be as ... settled in other manner that do not cause confusion. ...
    (comp.lang.c)
  • Re: C/C++ Ambiguity in Order of Evaluation
    ... The order of evaluation of subexpressions is determined by the ... precedence and grouping of the operators. ... A reference manual that implements a language standard should be as ... of any connection of precedence of operators with order of evaluation ...
    (comp.lang.c)