Object Swapping?
Michael van der Gulik
squeakml at gulik.co.nz
Sat Aug 19 03:22:45 UTC 2006
Lukas Renggli wrote:
>> We are a small group in Fontana learning Squeak together. We are
>> curious,
>> is there an object swapping function, like LOOM, built into squeak?
>
>
> #become:
Ah... if that's the right answer, there are some caveats:
1. become: will switch object pointers. becomeForward will make the two
objects the same as the argument to becomeForward.
2. It's (as far as I know) a slow method. Squeak has direct object
pointers rather than an object lookup table.
3. Be careful with dictionaries. If you swap object pointers, hashes
(especially identityHash) will change, which does bad things to
dictionaries. See also becomeForward:copyHash:. Be especially careful
with anything that's stored in the SystemDictionary.
4. Don't save your image after you test your code. Write your code, save
the image (and maybe your code using Monticello to local disk), run your
code, and then quit squeak and restart. Otherwise you may end up with a
corrupted image. I have been through a few. Also, keep periodic backups
of your progress in another directory or something.
Michael.
More information about the Squeak-dev
mailing list
|