<div>Hi Erlangers,</div><div><br></div><div>Is there is a way to find a position number of the field in the record:</div><div><br></div><div>1. At compile time (record_info)?</div><div>2. At runtime (I think not).</div><div>

<br></div><div>Motivation:</div><div>I use lists module and its functions like lists:keyfind/3 for dealing with records. I don't want to hardcode number to target certain record's field. I afraid that if I change order of fields in my records my code will be broken (It will be indeed). So, I do believe that it is possible to do something like:</div>

<div><br></div><div>...</div><div>-record(my_rec {</div><div>  name, age, gender</div><div>}).</div><div>%</div><div>ListOfRecords = [#my_rec{name = "John"}, #my_rec{name = "Peter"}, #my_rec{name = "Marry"}],</div>

<div>Value = "Peter",</div><div>%</div><div>case lists:keyfind(Value, ?get_filed_number(name, my_rec), ListOfRecords) of</div><div>...</div><div><br></div><div>I hope it is possible to define some sort of makro that will do the job...</div>

<div><br></div><div>Any ideas?</div><br clear="all"><div>Best regards,</div><div>Max</div><br><br>