Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!europa.chnt.gtegsc.com!news.mathworks.com!news.kei.com!simtel!col.hp.com!news.dtc.hp.com!hplextra!hplb!hpwin055.uksr!news.sweden!isonews.bbn.hp.com!hpbbrd!jensk
From: jensk@hpbbn.bbn.hp.com (Jens Kilian)
Subject: Re: Prolog syntax
Sender: news@hpbbrd.bbn.hp.com (News System)
Message-ID: <D7y595.2s0@hpbbrd.bbn.hp.com>
Date: Tue, 2 May 1995 10:31:52 GMT
References: <3nc9bb$6nu@newsserv.cs.sunysb.edu>
Organization: HP Mechanical Design Division
X-Newsreader: TIN [version 1.2 PL2]
X-Disclaimer: I do not speak for HP, I only *work* here.
Lines: 53

> In article 12609 of comp.lang.prolog 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!

[...]

> More specifically, I do not see why quoting an atom should change its
> operator properties.  IMHO, quoting an atom should affect only its
> lexical manipulation (performed by a tokenizer) and not the way it is
> syntactically parsed as an operator in a term (performed by the parser).

There is at least one Prolog system (TOY Prolog, described in "Prolog for
Programmers" by Kluzniak & Szpakowicz) where quotes are used to force an
operator to be interpreted as an atom (in TOY Prolog, operators can never
be quoted atoms).  In Edinburgish dialects, parentheses are used instead
(e.g., (+)/2 ).

The draft ISO standard explicitly says that an operator cannot be the
immediate operand of another operator.  This means that the term  * + *
(which is legal in Edinburgh Prolog) must be written as  (*) + (*)
in ISO Prolog.  In that respect, the dialects you tested seem to be
nonconforming (not surprisingly, since they predate the standard).

I don't know why the standardizers chose to make this restriction.  Perhaps
because of the asymmetry

		* + *		legal
		+ * +		illegal

On the other hand, the ISO standard allows operators as operands of terms
in functional notation and as list elements, without restriction:

	f(:-, :-)		[:-, :- | :-]

Are these legal in Edinburgh Prolog?

Greetings,

	Jens.
