
-------- Original Message -------- Subject: Re: Any Prolog language lawyer out there? Date: Tue, 19 Oct 2004 16:29:24 +0200 From: Bart Demoen bmd@cs.kuleuven.ac.be Organization: KULeuvenNet Newsgroups: comp.lang.prolog References: 41750912.8040102@cs.unipr.it
Roberto,
Am I correct if I say that all the 6 tested systems are /not/ violating the ISO Prolog standard because unary plus is not mentioned in its Table 7 (p. 19) and thus its presence and priority are implementation-defined? All the best,
Roberto
P.S. Standard or not standard, I find all this quite striking.
The + not figuring in ISO as fy, makes the situation murky. But - is in ISO as 200 fy. And one finds differences like:
In SICStus:
| ?- prolog_flag(language,_,iso). yes | ?- current_op(200,fy,-). yes | ?- functor(- 4,X,Y). X = -4, Y = 0 ?
while GNU-Prolog says:
| ?- current_op(200,fy,-). yes | ?- functor(- 4,X,Y). X = - Y = 1
The old DEC-10 reader (used in e.g. SICStus) contains the clauses:
read(atom(-), L, [Token-_|S1], Precedence, Answer, Layout, S) :- number_token(Token, Number), !, Negative is -Number, read_rest(S1, 0, Negative, L, Precedence, Answer, Layout, S). read(atom(+), L, [Token-_|S1], Precedence, Answer, Layout, S) :- number_token(Token, Number), !, Negative is +Number, read_rest(S1, 0, Negative, L, Precedence, Answer, Layout, S).
which seem to be responsible for the behaviour above. I think not ISO at all.
Moreover, if one retracts + as an operator, one should get syntax errors for +4, but here is SICStus again:
| ?- op(0,fy,+). yes | ?- write(+4). 4 yes
while GNU says:
| ?- op(0,fy,+).
yes | ?- write(+4). uncaught exception: error(syntax_error('user_input:2 (char:8) , or ) expected'),read_term/3)
Cheers
Bart Demoen