extensible RemoveAllSuchThat:

Jecel Assumpcao Jr jecel at merlintec.com
Wed May 7 08:05:39 PDT 2003


Hi, Paul!

It looks like you are trying to push Brian to make Slate catch up with 
and pass Io ;-)

On Wednesday 07 May 2003 11:08, Paul Dufresne wrote:
> I don't understand yet the difference between a ShallowCopy and a
> copy. But don't you need a plain copy here?

Any object is actually the root of a tree structure, since "knows" 
several objects who "know" other objects and so on. So when you copy an 
object, how deep should you go?

Smalltalk had the notion of "shallowCopy", "deepCopy" and plain old 
"copy". The first was the same as "clone" and created a new object that 
pointed to the exact same objects as the old one did. That is often not 
what you want - if a shelf includes a set of books, should a copy of 
the shelf share its books with the original one or get its own? 
DeepCopy would get you the second result by recursively walking the 
whole object tree.

A problem with deepCopy is that objects are so linked to each other that 
it might essentially copy the whole system! Or it might never finish 
copying a circular structure. So normally plain "copy" will do the 
right thing, somewhere in between shallow and deep. It might copy some 
objects the original knows and share others.

-- Jecel



More information about the Slate mailing list