[erlang-questions] Are nested records copied?
ANTHONY MOLINARO
anthonym@REDACTED
Mon Jun 3 19:34:30 CEST 2013
BTW, you'll probably learn a lot by checking out this video from the last Erlang factory
http://www.erlang-factory.com/conference/SFBay2013/speakers/ErikStenman
as it gives some good examples of what is happening in the heap and stack of a process and talks about term sharing and how it works.
-Anthony
On Jun 1, 2013, at 8:55 AM, Bryan Hughes <bryan@REDACTED> wrote:
> Thanks Bob - that is what I was thinking/hoping.
>
> On 6/1/13 8:50 AM, Bob Ippolito wrote:
>> 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"
>>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130603/0c768149/attachment.htm>
More information about the erlang-questions
mailing list