Mariano Martinez Peck wrote:
Hi guys. I am doing some experiments with FuelPackageLoader and I have a
problem with the initialization. All my unit tests pass but when trying to
export/import seaside/pier/magritte, I have a problem.
What I do basically, is to ask Metacello the list of packages that I need
to loaded for seaside and friends. The list is IN ORDER OF LOADING. So what
I do during the import is to load each package in the correct order (the
one Metacello told me). For each package I load, I initialize its classes
(at the end of the load of the package). The order I initialize classes for
a package is:

            ((aPackage classes select: [:each | each isBehavior])
                     sort: [:a :b | a allSuperclasses size < b
allSuperclasses size ])
                         do: [:aClass |
                            Transcript show: 'Initializing class: ', aClass
name; cr.
                            aClass initializeOnLoad]

and

Class >> initializeOnLoad
    (self class includesSelector: #initialize)
        ifTrue: [self initialize]


so...I am having a problem with seaside with a class and it looks like a
problem of the order of the initialize. Do you think something is wrong
with our approach? any idea?

thanks in advance,

I guess if you have two inheritance paths A <-- B --< C and A <-- B <-- D and C depends on D then an #initialize order of A, B, C, D is problematic. Some naive musings... 1. Have a mechanism to lazily invoke #initialize only when the class is first referenced. One way may be to load classes into a holding area in the image but install a proxy class that when referenced replaces itself with the one from the holding area. Your above code will ensure this happens for each loaded class by the end of the package load. 2. Parse the #initialize of C and D to determine dependency graph - but perhaps this is not statically defined. 3. Specify a requirement for #initialize code to hardcode a call to #initialize for any class it depends on. 4. Require packages to implement something like #initializeDependent to make them compatible with Fuel. I imagine the bootstrapping project has to solve a similar issue and pehaps share an approach.

cheers -ben



Reply via email to