record field names

Ulf Wiger (AL/EAB) <>
Fri Sep 16 16:33:18 CEST 2005


In order to eliminate name clashes, why not

Module:module_info({record, Rec, fields})

/Uffe

> -----Original Message-----
> From: 
> [mailto:]On Behalf Of Mats Cronqvist
> Sent: den 16 september 2005 16:22
> To: 
> Subject: record field names
> 
> 
>    feels like this is an faq, but i can't find it in the archive.
> 
>    according to the reference manual:
>    "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"
> 
>    now, as i understand it, there is no function, just 
> textual substitution 
> (like a macro).
> 
>    but why not? if there was a real, exported function 
> record_info/2 (just like 
> module_info), one could do a lot of cool things.
> 
>   such as turning a record into a tagged tuple;
> 
> readable_rec(Module,Rec) ->
>    
> lists:zip(Module:record_info(fields,element(1,Rec)),tl(tuple_t
> o_list(Rec))).
> 
>   or write a tool to check that all modules using a certain 
> record agree on its 
> definition.
> 
>    mats
> 



More information about the erlang-questions mailing list