[Newbies] Object clone

Xinyu Liu liuxinyu95 at gmail.com
Thu Jan 17 13:17:26 UTC 2008


Hi,

In squeak copy is implemented as:
^self shallowCopy postCopy

and deepCopy just copy 2 layers of instance, so if the object has tree like
sub instance,  postCopy must be implemented.

Best regards.
-Liu Xinyu

On Jan 16, 2008 2:11 AM, Randal L. Schwartz <merlyn at stonehenge.com> wrote:

> >>>>> "Marcin" == Marcin Tustin <mm3 at zepler.net> writes:
>
> Marcin> So, I take it that clone is a "stupider" (no postCopy
> polymorphism) version
> Marcin> of copy (or shallowCopy). Is that right, or does it do something
> odd?
>
> Object>>#clone looks like an optional-implemented primitive that
> does a #shallowCopy, but without the fallback-to-smalltalk that
> #shallowCopy
> performs.  Not sure why those are both in the image.
>
> I'd stick with #copy unless I was the implementor of the class being
> copied, and even then, I'd make copy "do the right thing". :)
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
> 0095
> <merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
> training!
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080117/ea934ccc/attachment.htm


More information about the Beginners mailing list