[erlang-questions] Is it possible to obtain all the records information at macros expanding time? E.g. Something like shell's rl().
Jayson Vantuyl
kagato@REDACTED
Sat Sep 12 00:17:23 CEST 2009
It's not identical to rl(), but there is record_info(). It's actually
not even a real function, as it gets expanded like a macro at compile
time. About the only place you see it much is creating Mnesia tables
(to get the field names).
Read all about it here: http://erlang.org/doc/reference_manual/records.html#8.7
8.7 is probably the more useful nooks in the Erlang Reference. It's
helpful to know stuff like this:
-record(moves,up,down,left,right).
record_info(fields,moves) -> [up,down,left,right];
record_info(size,moves) -> 5.
And most interesting:
#moves.down =:= 3.
X#moves.down =:= element(#moves.down, X).
On Sep 11, 2009, at 4:44 AM, Daniel Kwiecinski wrote:
> Hi folks,
>
> Is it possible to obtain all the records information at macros
> expanding
> time? E.g. Something like shell's *rl()*.
>
> Thank you in advance.
>
> --
> Kind Regards,
> Daniel Kwiecinski
--
Jayson Vantuyl
kagato@REDACTED
More information about the erlang-questions
mailing list