[squeak-dev] #copyFrom: vs #copySameFrom:

Levente Uzonyi leves at elte.hu
Wed Sep 28 13:12:34 UTC 2011


the two methods in the subject are for copying the values of the variables 
from one object to another. The two methods are basically the same, but 
there are slight differences:
- #copySameFrom: doesn't use primitive 168 which provides atomic copying 
if the receiver's class is the same as the argument's class.
- #copyFrom: doesn't copy the variables if they have the same name, but 
different indices in the two objects.

So my suggestion is to merge the two features into one method: use the 
primitive and copy the variables independently of their indices. But I'm 
not sure which name should we use.
#copyFrom: is widely used, but 
beginners used to expect it to work like #copyFrom:to: without an upper 
#copySameFrom: is not widely used, but it's also less confusing for 
Maybe a third name would be the best choice, e.g.: #copyVariablesFrom:,
#copySlotsFrom:, maybe #copyValuesFrom:.
What do you think?


More information about the Squeak-dev mailing list