Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!gatech!paladin.american.edu!zombie.ncsc.mil!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: <D894yv.HEG@hpbbrd.bbn.hp.com>
Date: Mon, 8 May 1995 08:59:18 GMT
References: <9511221.23905@mulga.cs.mu.OZ.AU> <3nkjnc$q0o@goanna.cs.rmit.edu.au> <9511918.22753@mulga.cs.mu.OZ.AU> <3o54fq$bgf@goanna.cs.rmit.edu.au> <9512302.17646@mulga.cs.mu.OZ.AU> <3o7sf3$14f@irix.uci.kun.nl>
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: 57

Henk Schotel (HSCHOTEL@vms.uci.kun.nl) wrote:
> Is, in your opinion, the following behaviour of a reader (LPA, but
> that is (supposed to be) compatible with Quintus, so probably
> has R. O'Keefe's approval) unavoidable or even desirable?

I don't know the details of Quintus' syntax, but it seems at least compatible
to the draft ISO standard.

> :-display((a:-b)).

OK, display/1 gets one operand with priority 0 (because of the parentheses).

> :-(a, b)

OK, functional notation with functor (:-)/2.

> BUT get an READ ERROR with:
> :-display(a:-b).  % Error 42: Syntax error in read.
>                   % Reading halts after :-

display/1 would get an operand with priority 1200, but operands in functional
notation must be atoms or terms with priority < 1000.

> The following does NOT give rise to a syntax error:

> :- (a :- b).
> a b

OK, :- used as prefix operator with an operand of priority 0 (parenthesized).

> and even more interestingly, neither does:
> :- a :- b.
> :-a b

I think this should give a syntax error, as neither operator is associative.

> Just discovered that the next query (without a space after the :-):
> :-(a :- b).
> again gave a READ error (same as the one above).

Again, functional notation with an operand of priority >= 1000.

> (I guess the last read error example (the no space one) is a real
>  implementation mistake, maybe due to the wrong handling of open
>  parentheses)

It's not a bug, it's a feature.  The space is how Prolog distinguishes between
operator notation (with a prefix operator) and functional notation:

	- (1, 2)	==	'-'(','(1, 2))
	-(1, 2)		==	'-'(1, 2)

That's the part that I hate ...

Greetings,

	Jens.
