[erlang-questions] The compiler "eats" structures which are not separated by commas

Vlad Dumitrescu <>
Fri Apr 20 13:34:52 CEST 2012


Hi Serge,

On Fri, Apr 20, 2012 at 13:27, Serge Polkovnikov
<> wrote:
> The compiler "eats" structures which are not separated by commas.
> start() ->
>     [
>      #haha{v=1}   %% No comma here
>      #haha{v=2}   %% No comma here
>      #haha{v=3}
>     ].

No, the code is equivalent to ((#haha{v=1})#haha{v=2})#haha{v=3}.

Try the following to understand:

-record(haha,  { a,b,c } ).
 start() ->
     [
      #haha{a=1}   %% No comma here
      #haha{b=2}   %% No comma here
      #haha{c=3}
     ].

regards,
Vlad



More information about the erlang-questions mailing list