[erlang-questions] newbie needing help getting started

Robert Virding <>
Wed Oct 14 16:45:10 CEST 2009


2009/10/14 Jayson Vantuyl <>

>
> Finally, a bit on syntax.  In Erlang, there is a sort of weird syntax based
> on punctuation.  The way that I try to explain it:
>
> * the dot (.):  This is used to finish a definition.
> * the comma (,):  This is used to separate a series of actions that occur
> in order.
> * the semicolon (;): This is used to separate branches, where control could
> go through one of the branches (but only one)
>

It's not weird, just different from C/Java. Look at (,) and (;) as
sequential operators (which they originally were) and it becomes much
clearer and simpler. (,) is first evaluate the lhs and then evaluate the
rhs, while (;) is first try the lh clause and if that fails then try the rh
clause. That is why there is no (;) after the last clause. So erlang has no
terminators like C/Java (;).

Look on the bright side, you don't have to wrap all blocks in begin ... end
which you do in C/Java.

Robert


More information about the erlang-questions mailing list