Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!news.mathworks.com!tank.news.pipex.net!pipex!peer-news.britain.eu.net!newsfeed.ed.ac.uk!hwcee!andrew
From: andrew@cee.hw.ac.uk (Andrew Dinn)
Subject: Re: operators and negative integers
Message-ID: <DMrK4H.9ME@cee.hw.ac.uk>
Sender: news@cee.hw.ac.uk (News Administrator)
Organization: Dept of Computing and Electrical Engineering, Heriot-Watt University
X-Newsreader: TIN [version 1.2 PL2]
References: <v58n36okog9.fsf@isa.cs.uq.edu.au>
Date: Wed, 14 Feb 1996 11:33:51 GMT
Lines: 37

Ray Nickson (nickson@cs.uq.oz.au) wrote:
: I just lost an argument with the implementors of our locally-developed
: Qu-Prolog system: I expected the string `- 1' (without the quotes) to
: be read as the tree -(1), while Qu-Prolog (and SICStus Prolog) reads
: it as the integer -1.  

...

: The other interpretation seems more logical to me, since it avoids an
: extra special case in the syntax of operators.

This is always an issue when tokenising and parsing programming
languages and I've never seen it resolved in favour of your prefered
option except by mistake. Your choice may seem more logical to you
from a parsing point of view but note that it implies you can never
write a negative integer constant in a program, command or term and
end up processing an integer value, e.g.

  ?- X = 1, integer(X).

  X = 1?

  ?- X = -1, integer(X).

  no.

  ?- format("Enter integer: ", []), read(X), integer(X).

  Enter integer: -1.

  no.


Andrew Dinn
-----------
Daran, nachdem die Wasserwogen / Von unsrer Suendflut sich verzogen
Der allerschoenste Regenbogen / Als Gottes Gnadenzeichen steht!
