[erlang-questions] Comma, semicolon. Aaaaa

Tue Sep 18 04:18:45 CEST 2007

I wrote that Erlang's comma (when not acting as the element separator
for tuples, lists, or function arguments) is an infix sequencing
operator, just like in C.

On 18 Sep 2007, at 11:31 am, Lone Wolf wrote:
[that he doesn't know anything about C, so doesn't know what I am
  talking about].

Read the message again, where I said what an infix sequencing  
operator is:
> E1, E2, E3 has the effects of E1 then
> E2 then E3 in that order and the value of E3.

In Algol 60, Simula I, Simula 67, Algol 68, Pascal, and Dijkstra's
notation, the semicolon is an infix operator.

	If S1 and S2 are statements,
	then S1 ; S2 means "do S1, then do S2".

In Algol 68, statements can be expressions, and this is generalised to

	If S is a statement and E is an expression
	then S ; E means "do S, then E, the result is the value of E".

BCPL used ";" for statement sequencing and "<>" for expression
sequencing.  C copied BCPL, but changed "<>" to ",".

There's a language called PL/I, which is a sort of Frankenstein's
monster made out of bits of Fortran, bits of Algol, and bits of COBOL,
the semicolon is a terminator.  Many people exploited the fact that
the Algols and Pascal have empty statements that no only have no
effect, but no tokens in them, to treat the semicolon as if it were
a terminator.  The Algol 60 block
	   x := 1;
            y := 2;
actually contains THREE statements.  The third one is invisible,
being an empty "do-nothing" statement, but it is definitely there.
You can see how confusion might arise.

	Algol			Erlang
	begin			(
	   S1;			   E1,
	   S2;			   E2,
	   S3			   E3
	end			)

The really horrible thing about C (faithfully copied, like so many
bad ideas, by C++, Java, C#, and JavaScript) is that *some*
statements end with a semicolon and some *don't*, and it's a property
of the statement which is which.  It is so much simpler in the Algol
family languages, where two successive statements always have a
semicolon between them, and it's also pretty simple in PL/I and Ada
where statements *always* end with a semicolon.  It's simple again
in Erlang where "statements" (really, "expressions") that are both
to be executed are ALWAYS separated by commas (and ONLY the comma
has this effect).

Lone Wolf, if this isn't clear enough, could you tell us which are
some of the programming languages you do know?

More information about the erlang-questions mailing list