[erlang-questions] Question about record_info

Ladislav Lenart lenartlad@REDACTED
Mon Jan 8 12:03:10 CET 2007


Hello,

How can I obtain info about a record given its name?
For example let's suppose I have an obligate person
record with fields: name, phone and address. I would
like to be able to do the following:
record_info(fields, person) %% -> {name, phone, address}

The following is what the reference manual says about the
topic (section 8.7 Internal Representation of Records):

----------------------------------------------------------------
To each module using records, a pseudo function is added
during compilation to obtain information about records:

record_info(fields, Record) -> [Field]
record_info(size, Record) -> Size

Size is the size of the tuple representation, that is one
more than the number of fields.
----------------------------------------------------------------

But whatever I try, I get either:
  * undef for record_info function,
  * illegal record info,
  * record Name undefined.

Please help.

Thanks,

Ladislav Lenart




More information about the erlang-questions mailing list