HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Initialization madness

12-14-2009, 11:34 PM#1
grim001
I have noticed a trend occuring where everyone must initialize their libraries in struct onInit methods, otherwise they face the possibility of something like this occuring:

Expand JASS:

Notice that if A wants to be usable by libraries that initialize stuff in a struct onInit, it must upgrade its own initializer to a struct onInit. Several libraries have fallen prey to this anti-trend: Table, AbilityPreload... I was just about to ask Dusk to change IntuitiveDamageDetection to use a struct onInit before I realized this.

Eventually, every library for which it could cause issues winds up using a struct onInit, and we're back to square one, with the libraries initializing in the same order, but now with mangled code. So what I'm proposing is that struct onInits no longer take precedence over EVERY library initializer. Only the ones within its own library/scope. Example below:

Expand JASS:
(Also, module onInits would run before just before their implementing struct onInits, rather than before everything like they do right now.)

This is a change that affects existing code, but as far as I can tell it should not cause any adverse effects. If anyone can find an example where it would cause issues, please post an example.

Basically, I have realized that once you allow different priority levels for initialization, you're going to wind up with a slippery slope effect where everyone has to compensate. It would be much better if you can assume that your required libraries are done initializing by the time yours starts.
12-15-2009, 12:00 AM#2
Hans_Maulwurf
Imo, A should be fully initialized, before B starts initializing, because B requires A. When requirements are the highest priority for initializing, I don't see any possible problems.
12-15-2009, 09:39 AM#3
DioD
vJass do not support priority settings...

best way to comment init line and init your systems inside other system.
12-20-2009, 09:57 AM#4
akolyt0r
grim +1
12-20-2009, 10:48 AM#5
Rising_Dusk
I support this. I remember when I first figured out about the priority stuff and wondered why the heck it wasn't like you suggest in the first place.
01-01-2010, 05:23 PM#6
Troll-Brain
Personally when i have the feeling this thing can happen, i use a dummy struct initializer instead, but i'm totally agree that it doesn't make any sense.

So what's new with that, someone asked it to Vexorian ?