[erlang-questions] Are nested records copied?
Bob Ippolito
bob@REDACTED
Sat Jun 1 17:50:59 CEST 2013
It's not copied in this case, nested records aren't flattened or anything
like that. Records are just tuples after all.
On Saturday, June 1, 2013, Bryan Hughes wrote:
> Howdy!
>
> I am working on section of code that will be dealing with a large number
> of records in a relatively tight loop and have a question in how Erlang
> constructs a nested record.
>
> If I define a person and manager record:
>
> 1> rd(person, {name, age}).
> person
> 2> rd(manager, {person, dept}).
> manager
>
> Then create a person record:
>
> 3> P = #person{name = bryan, age = 45}.
> #person{name = bryan,age = 45}
>
> And then a manager record:
>
> 4> M = #manager{person = P, dept = foo}.
> #manager{person = #person{name = bryan,age = 45},dept = foo}
>
> When the manager record is created, is the nested person record P
> referenced by the manager record M, or is it copied?
>
> Thanks,
> Bryan
>
> --
>
> Bryan Hughes
> *Go Factory*
> http://www.go-factory.net
>
> *"Internet Class, Enterprise Grade"*
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130601/d327e79a/attachment.htm>
More information about the erlang-questions
mailing list