Hakan Mattsson hakan@REDACTED
Mon Jun 28 07:51:23 CEST 1999

On Fri, 25 Jun 1999, Torbjorn Tornkvist wrote:

>Date: Fri, 25 Jun 1999 05:05:53 +1000
>From: Torbjorn Tornkvist <tobbe@REDACTED>
>To: Mickael Remond <mikl@REDACTED>
>Cc: erlang-questions@REDACTED
>Subject: Re: record_info/2 
>> What I am trying to do is get the list of fields of an object :
>> (The aim of the function is to replace a fields value by its name, 
>> without specifically knowing what kind of record I am manipulating)
>>    Record_name = element(1,Obj),
>>    %% Get list of fields
>>    List = record_info(fields, Record_name),
>record_info/2 is resolved at compile time, so you can't do the above
>(Remember, records is just syntactic sugar on top of tuples)

If the table happens to be a Mnesia table, you may use the function
mnesia:table_info/2 instead of record_info/2:

    TableName = element(1, Obj),
    FieldList = mnesia:table_info(TableName, attributes),

mnesia:table_info/2 is resolved in run time.


More information about the erlang-questions mailing list