Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!howland.reston.ans.net!vixen.cso.uiuc.edu!news.ecn.bgu.edu!feenix.metronet.com!uunet!allegra!alice!pereira
From: pereira@alta.research.att.com (Fernando Pereira)
Subject: Re: Prolog syntax
In-Reply-To: fjh@munta.cs.mu.OZ.AU's message of Sat, 22 Apr 1995 11:58:15 GMT
X-Nntp-Posting-Host: alta.research.att.com
Message-ID: <PEREIRA.95Apr22162433@alta.research.att.com>
Sender: usenet@research.att.com (netnews <9149-80593> 0112740)
Reply-To: pereira@research.att.com
Organization: AT&T Bell Laboratories
References: <9511221.23905@mulga.cs.mu.OZ.AU>
Date: Sat, 22 Apr 1995 20:24:33 GMT
Lines: 57

In article <9511221.23905@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus Henderson) writes:
   Should the following be syntax errors?

	   ?- display(* + *).		% 1

	   ?- display(1 '+' 2).		% 2

	   ?- display(X = *).		% 3

	   ?- display(X = '*').		% 4

   Personally, I think 1, 2, and 3 should be syntax errors.
   According to my reading of the draft ISO Prolog standard,
   1, 3, and 4 are supposed to be syntax errors.
   But according to the four Prolog implementations I have on hand
   (NU-Prolog, SICStus Prolog, SWI-Prolog, and Aquarius Prolog),
   none of them are syntax errors!
The Edinburgh Prolog term readers and others derived from them always
had the behavior you deplore. The fixity properties of atoms are
only used as needed to make terms syntactically correct, and quoting
an atom does not change its operator properties (it's a lexical, not a
syntactic manipulation). However, the precedence of an atom declared
as an operator is always present, eg:

| ?- display(+ + +).
+(+,+)
yes
| ?- display(+ * +).
! Syntax error
! between lines 22 and 23
! display(+ * +
! <<here>>
! )

in Quintus Prolog 3.1.1, 

1 ?- display(+ * +).

[WARNING: Syntax error: Unbalanced operators 
display(+ * +
** here **
) . ]

in SWI-Prolog 1.9.4.

I don't have the draft standard handy, but the behavior you deplore
doesn't seerm to have caused serious problems before, and it's in fact
quite convenient in many contexts.
--
Fernando Pereira
2B-441, AT&T Bell Laboratories
600 Mountain Ave, PO Box 636
Murray Hill, NJ 07974-0636
pereira@research.att.com
1-908-582-3980


