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

Serge Polkovnikov serge.polkovnikov@REDACTED
Fri Apr 20 13:54:53 CEST 2012


20 апреля 2012 г. 14:34 пользователь Vlad Dumitrescu
<vladdu55@REDACTED>написал:

> Hi Serge,
>
> On Fri, Apr 20, 2012 at 13:27, Serge Polkovnikov
> <serge.polkovnikov@REDACTED> 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}.
>

Is there any simple way to protect such lists against the behaviour?

>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120420/1f958c73/attachment.htm>


More information about the erlang-questions mailing list