f(a:-b,c) or f((a:-b),c) - How should compound args be parsed?
- From: "Brian Hulley" <brianh@xxxxxxxxxxxx>
- Date: 14 May 2005 02:41:00 -0700
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.
.
- Follow-Ups:
- Re: f(a:-b,c) or f((a:-b),c) - How should compound args be parsed?
- From: gary
- Re: f(a:-b,c) or f((a:-b),c) - How should compound args be parsed?
- From: Jan Wielemaker
- Re: f(a:-b,c) or f((a:-b),c) - How should compound args be parsed?
- Prev by Date: Re: deductive databases
- Next by Date: Re: f(a:-b,c) or f((a:-b),c) - How should compound args be parsed?
- Previous by thread: Re: Looking for "diff" algorithm.
- Next by thread: Re: f(a:-b,c) or f((a:-b),c) - How should compound args be parsed?
- Index(es):
Relevant Pages
|
|