Code loading/unloading order

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Code loading/unloading order

webwarrior
It is not documented.

What happens when I load a package?
Are all classes created first, and then methods are added, or classes are loaded one-by-one with all their methods?
What about Slots? Are they added to classes after all classes are loaded? Do they have their methods by that time?
What is order of loading of classes? Alphabetical, or using some resolution mechanism, or is it implementation detail?

What happens when I unload the package? Is it inverse of loading so order is reversed?
Reply | Threaded
Open this post in threaded view
|

Re: Code loading/unloading order

Guillermo Polito
Hi,

I think it is not documented, and it's usually strange that people write code dependent on this order. However, to anwer your questions, you can look at MCPackageLoader>>#basicLoadDefinitions. More specific below:

On Tue, Jan 24, 2017 at 3:07 PM, webwarrior <[hidden email]> wrote:
It is not documented.

What happens when I load a package?
Are all classes created first, and then methods are added, or classes are
loaded one-by-one with all their methods?

- new classes added
- new (versions of) methods are compiled
- old classes and methods removed

- retry definitions that were erroneous

- install all new methods
- notifications
- postloads
 
What about Slots? Are they added to classes after all classes are loaded?

No, they are added to the class when it is created
 
Do
they have their methods by that time?

It depends. If the class was not loaded before, it does not have methods. If the class existed and you're loading a different version, it'll have the old methods.
 
What is order of loading of classes? Alphabetical, or using some resolution
mechanism, or is it implementation detail?

It looks by looking at the code that they are sorted by dependency between them (for example, superclasses before subclasses).
But I did not look much further.
 

What happens when I unload the package? Is it inverse of loading so order is
reversed?

Apparently, (look at MCPackageLoader class>>#unloadPackage:) the order is reversed by dependency (first methods, then subclasses, then superclasses)
 

Guille 
Reply | Threaded
Open this post in threaded view
|

Re: Code loading/unloading order

webwarrior
Thanks.

Reason why I ask is because I ran into some issues with slots that depended on other classes in the package (when creating slot, like SomeSlot new valueClass: SomeOtherClass). I had to move slots into separate package to make it work.

Like when you work on your code it's all good, but then you load it in other image - and whoops... something's broken.
Reply | Threaded
Open this post in threaded view
|

Re: Code loading/unloading order

demarey

> Le 26 janv. 2017 à 12:25, webwarrior <[hidden email]> a écrit :
>
> Thanks.
>
> Reason why I ask is because I ran into some issues with slots that depended
> on other classes in the package (when creating slot, like SomeSlot new
> valueClass: SomeOtherClass). I had to move slots into separate package to
> make it work.

probably because dependency computation done by Monticello does not take into account slots.
would be a good addition.