| Bart Demoen 2005-08-07, 5:02 pm |
| Jan Wielemaker wrote:
> More interesting of course is what is right. I had a brief look at the
> ISO standard document. They say it is not allowed to have an operator
> as both infix and postfix. We should conclude allowing both prefix and
> infix is allowed, but they say nothing (unless I'm blind :-) about how
> to resolve possible ambiguity.
Prefix and infix is ok: -/1 and -/2 is an example.
>
> The basic algorithm of SWI-Prolog tries to resolve operators in the
> order INFIX, POSTFIX, PREFIX. Does this violate the standard or accepted
> practice? Is there an accepted test-set to ensure all Prolog systems
> behave the same?
The example with #- from LPTP is actually similar to the
regular -/1 and -/2:
?- current_op(X,Y,(-)).
X = 200
Y = fy ;
X = 500
Y = yfx ;
No
I tried http://www.sju.edu/~jhodgson/prolog...ramed_spec.html
with the query
?- functor((- - a), X, Y).
and it answers X = - Y = 1
In SWI it does:
?- functor((- - a), X, Y).
X = -
Y = 2
I don't think that the site by Jonathan Hodgson has any official
status, and the executable specification is written in GNU-Prolog so
maybe it is assuming GNU is ISO in some places where it isn't. I will
have a look in my ISO doc at work tomorrow, but it might be worth
checking with Jonathan who is currently the ISO/IEC JTC1/SC22/WG17
convener.
Cheers
Bart Demoen
|