Hi igor I cannot help but indeed we need a real brand new classbuilder with a nice MOP for instance migrating too. We will start to work on that probably december/january. Stef On Sep 23, 2010, at 12:03 AM, Igor Stasenko wrote:
Hello, guys
i want to do a simple thing, which can be expressed by following:
oldClass replaceWith: newClass migrateInstances: [:inst | ... ]
In my case, first, i installing a WeakFinalizationRegistry class, and then want to replace an old WeakRegistry class with it, silently and painlessly.
I end up with following script:
| old new oldClass newClass | old := OrderedCollection new. new := OrderedCollection new.
"migrate instances" WeakRegistry allInstancesDo: [:registry | | newr | old add: registry. newr := WeakFinalizationRegistry basicNew initialize. registry migrateTo: newr. new add: newr ]. old asArray elementsForwardIdentityTo: new asArray.
"replace the class"
oldClass := WeakRegistry. newClass := WeakFinalizationRegistry.
Smalltalk forgetClass: #WeakFinalizationRegistry logged: false. newClass superclass removeSubclass: newClass. newClass setName: #WeakRegistry. oldClass becomeForward: newClass.
--
it looks a bit hackish, and i wonder how to do that in more 'standard' way.
Initially replacing classes was:
oldClass removeFromSystem. newClass rename: #WeakRegistry
the problem with that, is that all compiled methods , which was referring to old class through association, still using it, and to get rid of them i have to recompile them.
-- Best regards, Igor Stasenko AKA sig.
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project