[Cuis] Copy vs Clone

David T. Lewis lewis at mail.msen.com
Wed May 13 22:22:15 CDT 2015


On Wed, May 13, 2015 at 11:24:09PM -0300, Juan Vuletich wrote:
> 
> Does anybody know why #clone was added to Squeak?
>

I do not know the historical background, but Object>>clone invokes #primitiveClone
in the VM. This is an efficient shallow copy, in which the object header and data
fields are copied to a newly allocated object, and the object hash and GC bits
are updated in the new copy.

I think that this must have been done for efficiency, to provide the fastest
possible means of shallow copying an object. The methods in the VM and in Object
are both old enough that they had no author initials, so this was a very early
optimization in Squeak.

Dave
 




More information about the Cuis mailing list