It's a bit of a simplification, reference classes are wrappers around environments. So if modifying a value in an environment would create a copy, then modifying the same value in a reference class will also create a copy.
The situation with modifying a vector is a bit complicated as it will sometimes be modified in place and sometimes be duplicated and modified (depending on whether its NAMED attribute is 1 or 2, and exactly how you're modifying it). Hadley On Thu, Jan 9, 2014 at 4:33 PM, Norm Matloff <matl...@cs.ucdavis.edu> wrote: > I have a question about reference classes, which someone here > undoubtedly can answer immediately, saving me hours of wading through > indecipherable internal code. :-) Thanks in advance. > > Reference class data is mutable, fine, but in what sense? Is it really > physical, or is it just a view given to the programmer? > > If for instance I have vector as a field in a reference class, and I > change one element of the vector, is it really true that the change is > guaranteed to be made in-place, no copying, no memory reallocation etc? > > Norm > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- http://had.co.nz/ ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel