#copyFrom: vs #copySameFrom:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

#copyFrom: vs #copySameFrom:

Levente Uzonyi-2
Hi,

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
bound.
#copySameFrom: is not widely used, but it's also less confusing for
beginners.
Maybe a third name would be the best choice, e.g.: #copyVariablesFrom:,
#copySlotsFrom:, maybe #copyValuesFrom:.
What do you think?


Cheers,
Levente

Reply | Threaded
Open this post in threaded view
|

Re: #copyFrom: vs #copySameFrom:

Eliot Miranda-2


On Wed, Sep 28, 2011 at 6:12 AM, Levente Uzonyi <[hidden email]> wrote:
Hi,

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 bound.
#copySameFrom: is not widely used, but it's also less confusing for beginners.
Maybe a third name would be the best choice, e.g.: #copyVariablesFrom:,
#copySlotsFrom:, maybe #copyValuesFrom:.
What do you think?

copyValuesFrom:
 


Cheers,
Levente




--
best,
Eliot



Reply | Threaded
Open this post in threaded view
|

Re: #copyFrom: vs #copySameFrom:

Colin Putney-3
On Wed, Sep 28, 2011 at 11:27 AM, Eliot Miranda <[hidden email]> wrote:
> copyValuesFrom:

+1