[erlang-questions] eep-0012 (Extensions to comprehensions)

Richard A. O'Keefe ok@REDACTED
Thu Aug 7 03:53:41 CEST 2008


On 7 Aug 2008, at 6:10 am, Gustavo Niemeyer wrote:
> - Allowing the last block to have a semi-colon on if/case/receive/etc.

No, where you want the optional semicolon is the FIRST case.
	case E0 of
	   ; P1 -> B1
	   ; ...
	   ; Pn -> Bn
	end

Someone else has already asked for multi-pattern case &c, so
	case E0 of
	   ; P11
	   ; P12 ->
		B1
	   ; P22
	   ; P23 ->
		B2
	   ...
	   ; Pn ->
		Bn
	end

Part of what is at stake here is that in Erlang the semicolon is NEVER
a terminator.  It's an operator.  Operators can be prefix as well as  
infix,
so a leading semicolon doesn't spoil the "semicolon is an operator"  
idea.
However, start treating semicolon as a terminator, and you will  
encourage
people to make the mistake of writing semicolons when they mean commas.
I know I can make that kind of mistake, which is why I always put
semicolons at the beginning of lines and commas at the ends.

Concerning [1,2,] and {3,4,}, I am aware that C allows an extra comma  
in some
kinds of list, and I've used that feature.  There are at least three
situations:
(a) You are typing something like this.

     It is easy to bend any decent text editor so that if you press the
     ']' or '}' key it will erase a preceding ','.  (Doing this in the
     presence of comments is not so easy, but at least Erlang comments
     are confined to a single line.)

(b) You are editing existing code and want to swap things.

     The editor I use has "swap terms" commands that leave the
     punctuation marks where they are and moves what's between them.
     This is useful in C, Pascal, Fortran, Ada, Eiffel, Prolog, ooh,
     such a lot of languages as well as Erlang.

(c) You are reading someone else's code.

     I don't believe trailing commas are a help here.

My point here is that *some* issues (lists separated by commas, or
for that matter semicolons) crop up in lots of languages, so that
editor support has much higher payoff than support in specific
programming languages.  And another point is that if you have a
decent editor you don't have to wait for the Erlang community to
decide you are right in order to get the same practical benefits
you are hoping for.  Maybe enough other people agree with you
that this change will happen.  In the mean time, there is no need
for you to suffer.

--
If stupidity were a crime, who'd 'scape hanging?










More information about the erlang-questions mailing list