Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!swrinde!howland.reston.ans.net!Germany.EU.net!Munich.Germany.EU.net!ecrc!news
From: joachim@ecrc.de (Joachim Schimpf)
Subject: Re: Prolog syntax
Message-ID: <D7Lp31.oI@ecrc.de>
Sender: news@ecrc.de
Reply-To: joachim@ecrc.de
Organization: European Computer-Industry Research Centre GmbH, Munich, Germany
References: <9511221.23905@mulga.cs.mu.OZ.AU>
Date: Tue, 25 Apr 1995 17:11:24 GMT
Lines: 45


In article 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.


Many years ago there was a lot of confusion because some Prologs (and
early versions of the BSI standard proposal) assigned similar meaning
to the quotes. Nowadays, to my knowledge, all major systems agree that
quotes should have the only function of grouping characters into tokens
(e.g. to make atoms like 'X' '123' 'a b' 'c++'). I think it would not
be of much help if you deviated from that with your Mercury syntax.

Removing the operator-property from a token can portably be done by
adding parentheses, e.g.

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

makes a syntax error on all platforms, I believe.

So, to allow for better error messages I think a good compromise would
be to make errors (or warnings) for 1, 3, 4, 5 and to allow only

	?- display((*) + (*)).		% 6

	?- display(X = (*)).		% 7

i.e. require parentheses whenever you use an operator as a plain atom.

---------------------------------------------------------------------------
 Joachim Schimpf                                 Email   joachim@ecrc.de 
 European Computer-Industry Research Centre      Phone   +49 89 92699 111
 Arabellastrasse 17, D-81925 Munich, Germany     Fax     +49 89 92699 170



