semantics of #clone?
Joshua 'Schwa' Gargus
schwa at cc.gatech.edu
Tue Jun 24 06:41:55 UTC 2003
Thanks for both of your answers,
Joshua
On Tue, Jun 24, 2003 at 02:16:53AM +0300, Lex Spoon wrote:
> Yoshiki.Ohshima at acm.org wrote:
> > Josh,
> >
> > > What are the semantics of #clone? Object>>clone has no method
> > > comment. How is it different from the intended meaning of
> > > #shallowCopy?
> >
> > I guess some other people have better ansser, but for me, #clone is
> > ensured to be more primitive and faster. Since it doesn't nil-out or
> > zero-out the newly created object, it is faster for objects like
> > Bitmap. In the other words, #clone is thin layer on the primitive,
> > while #shallowCopy has more flexibility to do something different.
> >
> > # I somehow am feeling that #clone is added later, in 2.x days.
> >
>
> I have thought of it as slightly more primitive, too. A shallow copy of
> an OrderedCollection, for example, might copy slightly more deeply than
> a #clone would (hmm, and that's what it does).
>
> Right now, Squeak's clone does do as much as nil out the variables --
> it's in fact the same primitive as the default shallowCopy. This seems
> like a good idea for Squeak, where safety is a higher priority than
> speed.
>
> Lex
More information about the Squeak-dev
mailing list
|