[erlang-bugs] parser/preprocessor bug
Robert Virding
robert.virding@REDACTED
Fri Nov 18 22:51:08 CET 2011
Originally the parentheses were mandatory but then the need for them around an record expression was removed to "improve" the syntax. Only in some cases though. Sorry for griping but I think it was a bad change. Other people have had exactly the same errors.
Robert
----- Original Message -----
> On Fri, Nov 18, 2011 at 03:46:16PM +0100, Joe Armstrong wrote:
> > On Fri, Nov 18, 2011 at 2:16 PM, Vlad Dumitrescu
> > <vladdu55@REDACTED> wrote:
> >
> > > Hi,
> > >
> > > On Fri, Nov 18, 2011 at 14:11, Joe Armstrong <erlang@REDACTED>
> > > wrote:
> > > > -module(bug).
> > > > -compile(export_all).
> > > > -record(bug,{a}).
> > > > test() ->
> > > > [#bug{a=1} #bug{a=2}].
> > >
> > > It's not a bug, it's the same as
> > >
> > > test() ->
> > > B = #bug{a=1},
> > > [B#bug{a=2}].
> > >
> > >
> > Ouch - oh dear you're right.
> >
> > When I wrote this I thought #bug{a=1} is syntactic sugar for
> > {bug,1}
> > therefore [#bug{a=1} #bug{a=2}] is the same as [{bug1,} {bug,2}]
> > which is
> > an invalid list.
>
> I have not tried but you can think of it like that:
> [#bug{a=1} #bug{a=2}]
> is
> [{bug,1} #bug{a=2}] %% uncertain if valid
> is
> [setelement(2, {bug,1}, 2)]
>
> since R#bug{a=A} is syntactical sugar for (kind of)
> if is_record(R, bug) -> setelement(2, R, A) end
> in the context of your record definition.
>
> >
> > /J
> >
> >
> >
> >
> >
> > > regards,
> > > Vlad
> > >
>
> > _______________________________________________
> > erlang-bugs mailing list
> > erlang-bugs@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-bugs
>
>
> --
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
>
More information about the erlang-bugs
mailing list