How to convert pools into modules
Last updated at 4:38 pm UTC on 16 January 2006
Andreas Raab wrote:
- How do we fix those in particular considering that custom images may contain many classes that may reference pools?!
Those classes that already use pools should continue to work fine until you recompile pool-referring code–I don't actively destroy existing pools. But creating classes that use pools wouldn't work anymore.
And to be able to recompile (former) pool using classes you need to
A) convert their pools into (pool) modules.
B) Convert existing code that accesses the pool dictionaries directly. This is typically only pool intialization code (unless you write naughty self-modifying code or some such ;-).
To do A you create a subclass of ModuleRefactorer, and fill in the info by overriding #newModulesForPools. Search for the existing implementor of that message to see how to do this. Check ModuleRefactorer 'convert pools' category to see the code that does this (but you shouldn't need to know how it is done). You run this code by executing "TheRefactorerClass run". Save the image before running that–you'll probably need a couple of tries to get it right.
To do B, you change the pool initialization code that sets up the pool vars to define them as vars in the pool module instead. The CS released as update 4681 holds the code that converts the necessary code in the standard image. That CS should be a good reference point for doing this, it holds conversions both for simple pool init code and for some more naughty code.
- The other bug is that apparently the set of dictionary messages sent from the compiler is not understood by modules. I don't think they should be understood (modules are not dictionaries) or at least in a rather limited way (through their exported names?!).
Right, I intentionally did not imitate the Dictionary protocol.
There is unfortunately no simple way to do any automatic conversion, but simple pool initialization code should be simple to convert.
A possible solution is to make pools fileIn-able again. It would mainly mean putting back pool lookups in the code that binds upper case variable names to values. It's on my list (though a list of what, I don't know).
But you won't be able to use this code as proper module code anyway as pools break modularity.