[erlang-questions] Erlang Shell and record_info ??

Lukas Larsson lukas@REDACTED
Thu Jul 26 14:27:34 CEST 2007


Hi,

You are supposed to use the name of the record as the last argument in
record_info and not the record it self. So in your example that would
be record_info(fields, a). Used like this record_info works perfectly
in the shell.



On 7/26/07, Sanjaya Vitharana <sanjaya@REDACTED> wrote:
>
>
> Hi,
>
> Reference Manual says:
>
>
> 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
>
> It's understandable, but is it not a good idea to include it to erlang
> shell??
>
>
> thanks
>
> Sanjaya Vitharana.
>
> 2> rl().
> ok
> 3>
> 3> A=rd(a,{b,c,d}).
> a
> 4> A.
> a
> 5> rl().
> -record(a,{b,c,d}).
> ok
> 6> B=#a{}.
> #a{b = undefined,c = undefined,d = undefined}
> 7>
> 7>
> 7>
> 7> B#a.c.
> undefined
> 8>
> 8> record_info(fields,B).
> ** 2: illegal record info **
> 9>
> 9> record_info(size, B).
> ** 2: illegal record info **
> 10>
> 10> C=B#a{c=rtest}.
> #a{b = undefined,c = rtest,d = undefined}
> 11>
> 11> B#a.c.
> undefined
> 12> C#a.c.
> rtest
> 13>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


-- 
Lukas Larsson

Software Engineer

Erlang Training and Consulting Ltd



More information about the erlang-questions mailing list