[erlang-questions] Field name to tuple element number at compile time

Joel Reymont <>
Wed Aug 27 17:16:40 CEST 2008

#foo.bar, or generally #rec_name.field does it.

This is perfectly valid:



-record(foo, {bar, baz}).

t() ->

On Aug 27, 2008, at 4:01 PM, Joel Reymont wrote:

> Suppose I have -record(foo, { bar, baz }). I understand that I can  
> do record_info(fields, foo) and get a list of fields at compile time.
> Is there a way to translate bar into 2 at compile time as well?


More information about the erlang-questions mailing list