Re: Any Prolog language lawyer out there?

From: Bart Demoen (bmd_at_cs.kuleuven.ac.be)
Date: 10/19/04


Date: Tue, 19 Oct 2004 16:29:24 +0200

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



Relevant Pages

  • Re: Any Prolog language lawyer out there?
    ... >> the ISO Prolog standard because unary plus is not mentioned in its Table 7 ... >> P.S. Standard or not standard, I find all this quite striking. ... with 2-complements representation one must write the ...
    (comp.lang.prolog)
  • Re: rem(X,Y) and mod(X,Y)
    ... who created the standard knows about the difference between mod and rem. ... X div Y division with floored result ... ISO, ECLiPSe and SICStus agree on this issue (div is not an evaluable ...
    (comp.lang.prolog)