[erlang-questions] Bug ?!

Richard A. O'Keefe <>
Fri Oct 6 00:14:04 CEST 2006

I wrote:
	> It's just that I have painful memories of ",.." in DEC-10 Prolog.

Richard Carlsson <> asked:
	Care to elaborate?  (I've been fiddling with list syntax
	variations, and I was thinking that "[x,y,..]" would be an
	improvement on "[x,y|_]", on several levels:  less prone to
	undetected typo mistakes, easier to write, and easier to read.)
Problem 1:  is ,.. one token or two?
 (a) if you make it one token, then you have all sorts of problems:
   (1) ,.. is one token but in [.,.,.] ,. is two tokens, and in
       [...,...,...] ,... is two tokens again, and of course ,.2 had
       better be comma nought-point-two.
   (2) careful writers who put spaces after commas want to put a space
       after this one, [a, b, .. c]
 (b) if you make it two tokens, then you hve other problems:
   (1) if you can have a space there, why not a newline? why not a comment?
       So X = [1, 2, 3,
		% this can go on for some time
		.. L]
   (2) you have a token which would otherwise belong to an established
       class of tokens (including +, ++, .+, --, -, .-, ..., ...., ....)
       but which can only occur in one place and then doesn't mean what
       they do.
Problem 2:  ,.. just plain doesn't work the way people expect.
    They expect to write
	[..,X,Y] = L		% oops, only allowed at end
	[X,Y,..] = L		% oops, something must follow ..
	[X,Y..Z] = L		% oops, a comma must precede ..	
	[X,Y,..,Z] = L		% oops, a comma may not follow ..
	[X,Y,..Z] = L		% !!OOPS!! I was expecting Z to be the
				% last element of L, but it's a tail!

In fact, for someone fluent in Latin-based writing systems that make
use of ellipses, ,.. is appallingly HARD to get right.  In particular,
your [x,y,..] is one of the cases that wasn't allowed, any more than
[x,y|_] was allowed.

When ,.. was removed from Prolog, no-one was sorry to see it go.

Given that . has so many other uses, I would expect
that ,.. would be MORE prone to mistakes.
Given the conflicts between ,.. and common practice in natural language,
and the absence of such conflicts between | and natural language,
I would expect ,.. to be HARDER to read.

There's no enemy so dangerous as a false friend.

More information about the erlang-questions mailing list