[PPL-devel] [Fwd: Re: Any Prolog language lawyer out there?]

Roberto Bagnara bagnara at cs.unipr.it
Thu Oct 21 12:06:27 CEST 2004



-------- Original Message --------
Subject: Re: Any Prolog language lawyer out there?
Date: 21 Oct 2004 10:00:48 GMT
From: Jan Wielemaker <jan at ct.xs4all.nl>
Reply-To: jan at nospam.swi.psy.uva.nl
Organization: SWI, University of Amsterdam
Newsgroups: comp.lang.prolog
References: <41750912.8040102 at cs.unipr.it> <1098196164.417498 at seven.kulnet.kuleuven.ac.be> <slrncnaat8.jkn.jan at ct.xs4all.nl> <87acuijutl.fsf at gondolin.bb.bawue.de> <1098259920.942884 at seven.kulnet.kuleuven.ac.be> <1098274154.598785 at seven.kulnet.kuleuven.ac.be> <77bbf36a.0410210015.1db2726c at posting.google.com>

In article <77bbf36a.0410210015.1db2726c at posting.google.com>,
Mats Carlsson wrote:
> I made a mistake in my previous posting, so here goes again.
> 
> Bart Demoen <bmd at cs.kuleuven.ac.be> wrote in message news:
<1098274154.598785 at seven.kulnet.kuleuven.ac.be>...
>> "A term which is the name - followed directly by a numeric constant,
>> denotes the corresponding negative constant"
>> 
>> In the standard "directly" means something like "with no space in between".
> 
> That must be wishful thinking on your part.  There is no such
> definition of "directly" in the document.  I too have the standard
> document, from which I quote the relevant grammar rules:

Its true that _directly_ is not defined.  The document (to which I
have access now by miracle :-) however uses the word 'followed' pretty
often and in many situations explicitly states whether or not layout
is allowed.  In this particular case it doesn't say anything, but it
uses the word 'directly', which might indicate they wish to say
something important.  Appearently the document should have been
explicit here.

Also, considering Prolog doesn't provide syntax for breaking long
numbers, it would be strange to have syntax that allows for breaking
between the - and its number.

> So clearly, there can be space, even comments, between the '-'
> and the digits.  BTW, the same applies to [/*this atom*/] and {/*this atom*/}.

Yes, but commenting inside [] and {} makes sense considering they are
a special case of something that is normally filled with content.
(As a sidenote, I still think [] and {} should not have been atoms
and the atom should be written '[]')

I see nothing but confusion in -/*this is a negative integer*/4

>> That decides the issue I think: - 4 should not be read as a negative integer;
> 
> To the contrary, it should.

Reading the standard (6.3.1.2 and 6.4) I think Mats is right that the
formal reading allows for layout between - and the digits.  I'm not
sure whether this was intentionally though.  What is the rationale?

In a functional language it doesn't make much difference whether the
parser returns -4 or the expression optimiser changes -(4) into -4.
For Prolog it does matter.  -4 and -(4) are really different beasts.

For SWI-Prolog I'm inclined to conform to the consensus of this
discussion and add a style warning, suggesting people to write either
-4 or -(4).

	Cheers --- Jan

B.t.w.	I think the original post was more about handling +4.  I cannot
	find anything which suggests that +4 should be read as 4, so I
	guess it must be read as +(4).  The Prolog world appears deeply
	divided here.  SWI, SICStus and YAP read +4 as 4, while hProlog,
	Ciao and gprolog read it as +(4).  My SICStus version is very
	old (3.7.1), so this may be corrected.

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it



More information about the PPL-devel mailing list