Dolphin deepCopy, seems deeper than I thought?

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

Dolphin deepCopy, seems deeper than I thought?

Christopher J. Demers
I have been using Smalltalk for 8 years.  I always thought of deepCopy as a
copy of copies one level deep. See Q5 at the Smalltalk FAQ at
http://www.ipass.net/~vmalik/smalltalk.html#Q5 .  It seems that deepCopy as
implemented in Dolphin 5 is a really deep copy.  Am I just tired or does
Dolphin's deep copy really go all the way?  Are all modern Smalltalk's doing
it this way?  Does ANSI say anything about this?  The FAQ I mention was just
reposted just this month with the same deepCopy info as on the web site.  I
guess the FAQ needs to be updated.

I only just noticed this deepCopy issue while trying to understand why I was
getting unexpected duplicated objects.  I know I can work around this.  I
was just surprised to see it working differently than I always thought it
did.  Am I the only one surprised by this?  Any thoughts?

Chris


Reply | Threaded
Open this post in threaded view
|

Re: Dolphin deepCopy, seems deeper than I thought?

Blair McGlashan
Chris

You wrote in message news:b3mqj3$1o4f94$[hidden email]...
> I have been using Smalltalk for 8 years.  I always thought of deepCopy as
a
> copy of copies one level deep. See Q5 at the Smalltalk FAQ at
> http://www.ipass.net/~vmalik/smalltalk.html#Q5 .  It seems that deepCopy
as
> implemented in Dolphin 5 is a really deep copy.  Am I just tired or does
> Dolphin's deep copy really go all the way?  Are all modern Smalltalk's
doing
> it this way?  Does ANSI say anything about this?  The FAQ I mention was
just
> reposted just this month with the same deepCopy info as on the web site.
I
> guess the FAQ needs to be updated.
> ...

Don't know about other St's now. When designing the basic Dolphin class
library we tried to maintain compatibility with Blue book Smalltalk where
possible, although we thought its one-level deep copy was virtually useless.
Probably due to this lack of utility, and the fact that it didn't actually
do what its name implied, it was removed from VisualWorks at some point.
Therefore we felt free to implement such that it does what it said on the
tin, i.e. as a true, recursive, deep copy.

There are 3 types of copy in Dolphin:

#shallowCopy
#deepCopy
#copy

The first two have a standard implementation, and do what the selector says.
The last can be implemented in whatever manner is appropriate, although the
default is a #shallowCopy, with #postCopy sent to that to provide a hook for
objects to perform class specific deepening of the copy and/or
reinitialization.

#deepCopy and #shallowCopy are not covered by the ANSI standard. Oddly #copy
is, even though it is difficult to specify it at all precisely.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: Dolphin deepCopy, seems deeper than I thought?

Bill Schwab-2
Blair,

> There are 3 types of copy in Dolphin:
>
> #shallowCopy
> #deepCopy
> #copy
>
> The first two have a standard implementation, and do what the selector
says.
> The last can be implemented in whatever manner is appropriate, although
the
> default is a #shallowCopy, with #postCopy sent to that to provide a hook
for
> objects to perform class specific deepening of the copy and/or
> reinitialization.
>
> #deepCopy and #shallowCopy are not covered by the ANSI standard. Oddly
#copy
> is, even though it is difficult to specify it at all precisely.

FWIW, I had an interesting crash-causing (OS shut me down kind of crash) bug
that turned out to be the result of poor #copy behavior.  My first "real"
use of Squeak was to study copying of a Morph and its submorphs for
comparison with the offending (non-graphical) objects.  #postCopy turned out
to be the answer, and I was able to fix the problem easily once I understood
it.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]