[net.lang.prolog] New List syntax

cdsm@icdoc.UUCP (07/11/86)

Recently the French standards committee made a proposal for
improving the syntax of lists in Prolog programs. I'd like to
conduct a poll of reactions to this, without expressing
personally or for the British standards committee any commitment
to or rejection of the proposal.

Context: The earliest Prolog implementations used the notation
A.B to signify a cons pair, and  a.b.c.nil for a proper list.
DEC-10 Prolog introduced the notation [a,b,c] for a proper list
which everyone agrees is more readable, and they also introduced
[a,b|C] for a compound list after the fashion of LISP
S-expressions - (a b . C). This gives rise to confusion: is the
functor of a list . or | ? (in most Edinburgh implementations it
is still .), and what becomes of degenerate expressions such as
[a,b|c,d]? (implementations vary wildly). Can one declare . as
an operator and still write A.B and a.b.c.[]? (In many but not
all implementations one can, with varying restrictions.) What is
the meaning of 1.2 (or, even worse, 1.2.3)?

The new proposal is [A].B for a cons pair, [a,b,c] for a proper
list and [a,b].C for a compound list. Note that this is a
DENOTATION which involves the THREE characters [ ] and ., and .
is NOT a standard operator, but is still the functor of a list.
To give a feeling for this, here are a couple of familiar
routines:

	nrev([A].B, C) :- nrev(B,D), append(D, [A], C).
	nrev([], []).
	append([], A, A).
	append([A].B, C, [A].D) :- append(B,C,D).
	?- nrev([1,2,3,4,5,6,7,8,9,10],X).

Note that one can use this notation recursively, e.g.
[a,b,c].[c,d].E or even [].[a], which means the same as [a]; but
multiple denotations for the same object are not a new thing
(e.g. numbers).  One can also easily extend it to string
denotations as in "abc".D (whatever meaning is attached to
strings). Thus "abc".[fred,joe]."def" would be a nice way to mix
character and atom lists. It is still necessary to provide a distinction 
between . for lists and the end of statement terminator, but this is
little different than at present.

Questions:
1. Have you found the current syntax for lists hard/confusing to
learn/teach?
2. Were you aware that '.' is normally the list functor?
3. Do you think the present notation needs to be rationalised in
some way (not necessarily by this method)?
4. Do you have any objections to this new notation? - either
rational or intuitive?
5. Do you like the new notation, or could you at least live with
it?

Please mail responses to cdsm@doc.ic.ac.uk or cdsm@icdoc.uucp.
Do NOT post them direct to the network. I will summarise and
pass on any interesting comments.

Chris Moss, Imperial College, London.