[erlang-questions] Dynamically access record fields

Jeremy Ong jeremy@REDACTED
Mon Feb 11 01:10:29 CET 2013


On Sun, Feb 10, 2013 at 4:07 PM, <ok@REDACTED> wrote:

> > On Sat, Feb 9, 2013 at 2:33 PM, Dmitry Kolesnikov
>
> > What I was saying was that you can't do something like
> >
> > Field = a,
> > V2 = setelement(#foo.Field, V1, "A+")
>
> Yes.  Like it says on the box, "records".
> You can't do this in Pascal, Modula, Modula2, Oberon, Ada, C, ...
> Records are not dictionaries and do not store field names.
> That's pretty much the _point_ of records, actually.
>
> But you *CAN* do
>
>     Index = #foo.a,
>     V1 = setelement(Index, V1, "A+")
>
> It's all spelled out in the manual.
> In this case, section 9.3, "Accessing Record Fields",
> second paragraph.
>
>
> And I'm doing exactly this. I'm arguing pure semantics, not *capability*.

I just don't see the harm in allowing the former, but I'm completely
prepared to ignore this issue entirely for now.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130210/10d0ca5a/attachment.htm>


More information about the erlang-questions mailing list