[erlang-questions] Why can't I use variables to denote members of a record?

Ulf Wiger <>
Sun Nov 29 10:51:51 CET 2009

Tony Arcieri wrote:
> I ran into a case where it would really be helpful to do:
> Rec#some_record{Member = Value}
> And the Erlang preprocessor bitches:
> Am I the first one in the history of Erlang to desire this behaviour?

Not at all. It has in fact been debated quite a lot over
the years.

I once wrote a parse_transform called exprecs that offers
a compromise by letting you 'export' a record, thereby auto-
generating accessor functions for that record.


I'm guessing that this won't entirely satisfy your needs,
but if so, perhaps you can use it as a starting point for
some similar transformation?

Ulf W
Ulf Wiger
CTO, Erlang Training & Consulting Ltd

More information about the erlang-questions mailing list