[erlang-questions] Generating a variable in a macro

Mats Cronqvist <>
Wed Jan 10 09:45:02 CET 2007


Thomas Lindgren wrote:
> --- Mats Cronqvist <>
> wrote:
> 
>> Thomas Lindgren wrote:
>>> --- Mats Cronqvist <>
>>> wrote:
>>>>    why the record_info functions are not laid out
>> in
>>>> the beam files (like the 
>>>> module_info functions) is a mystery to me. surely
>>>> that would be The Right Thing 
>>>> (tm).
>>> Well, that might give users the idea that records
>> are
>>> more than syntactic sugar for tuples. But they're
>> not.
>>
>>    that sounds pretty weak...
> 
> "Records" as used today are declared in include files
> which then are textually inserted into one or many
> modules. A record declaration does thus not in general
> have a unique point of definition. A single record
> name #r can also be declared differently in different
> modules. There is finally no general way to know that
> the tuple {r, foo, 4711} should use the record_info
> definition in mod1 or the one in mod2. Or neither.

   this is actually exactly why i originally proposed exporting a record_info/2 
function from every module; so that i could write a tool to check that all my 
modules actually DO use the same definition of all records.

   i think we can all agree that records suck (as does all macros). but i think 
a record_info function would make them suck slightly less.

   mats



More information about the erlang-questions mailing list