[Seaside] Set restoreFromSnapshot: - why additional snapshotCopy?

Lukas Renggli renggli at gmail.com
Tue May 27 13:43:29 UTC 2008

>  I stumbled across the snapshotCopy / restoreFromSnapshot: pair of methods
> of class Set. What puzzles me is that restoreFromSnapshot: needs to do an
> additional snapshotCopy of the stored object. So each Set is snapshot-copied
> at least twice if put in the state.

The internal implementation of Collections differ heavily in Smalltalk
dialects. For example the Set in Squeak is implemented as a container
object that references an array of elements. In VisualWorks the Set is
an indexable object itself.

In Squeak we need to make sure that both objects - the set container
and the array - are properly copied. That's why the set is copied
first before restoring into the existing object. The tests extensively
cover this fact.

Because of these differences between the platforms all the
#snapshotCopy and #restoreFromSnapshot: code is in the platform
dependent code. Obviously the porters to VisualWorks just took the
Squeak code, even if that code would not be necessary in this case. It
doesn't hurt either, though.


Lukas Renggli

More information about the seaside mailing list