Hello,
Only the tuple which is the record and the immidiates (i.e. small int,
atom, pid, ref etc) will be copied. All other parts use pointers
internally and the same pointers will be copied into the correct
places within the tuple. So in this case a new 6 word memory block
will be created and filled with the atom undefined and finally the new
counter.
I think that the compiler does some optimization based on updating
tuples within the same function body, though I've forgotten what it is
it does.
X1 = X0#r{a=foo(),b=bar(),c=baz()},
will be optimised, while
X1 = X0#r{a=foo()},
X2 = X1#r{b=bar()},
X3 = X2#r{c=baz()},
will not. It always tries to do this optimisation but it is generally seldom safe to do it.
Robert