Skip to content

call __init__() in modules at init time #5960

Merged
merged 7 commits into from Feb 27, 2014

3 participants

@JeffBezanson
The Julia Language member

The improvement here should be obvious. Less duplication, more locality, etc.

This will also make it very easy for packages to support precompilation.

This does the simplest thing that could work, leaving the following unsolved:

  • Order of initialization (though there is a stack, such that outer modules are initialized before inner)
  • Idempotence (though the system itself will not try to init a module more than once)
@StefanKarpinski
The Julia Language member

This rather sneakily sets a precedent about reserved names, implicitly make _name the de facto standard pattern. It might be better to do something like __init__.

@JeffBezanson
The Julia Language member

That name is fine with me.

JeffBezanson added some commits Feb 26, 2014
@JeffBezanson JeffBezanson Merge branch 'master' of github.com:JuliaLang/julia into jb/module_init 0efcc4c
@JeffBezanson JeffBezanson rename _init to __init__ 58867fc
@JeffBezanson JeffBezanson better module initialization order: init inner modules after outer mo…
…dules

are complete and initialized.
b5df426
@JeffBezanson JeffBezanson fix #5963 df0921b
@JeffBezanson JeffBezanson Revert "fix #5963"
This reverts commit df0921b.
db94ed6
@JeffBezanson JeffBezanson add NEWS for module init, and clean up Base initializer
9693654
@JeffBezanson JeffBezanson merged commit 0049f4a into master Feb 27, 2014

1 check passed

Details default The Travis CI build passed
@vtjnash
The Julia Language member
vtjnash commented Feb 28, 2014

why is this order best?

are you waiting to init inner modules until after the outer module is init, or before it is init, but after it is closed?

@JeffBezanson
The Julia Language member

I think officially, the order has to be undefined for now, since we have no way to guarantee it after deserialization. But I tried to pick an approach that would be less likely to cause problems.

Inner modules should be init after all their outer modules are closed, so they don't try to refer to something that might not have been defined yet. I also init outer modules first, but that's less important.

@JeffBezanson JeffBezanson deleted the jb/module_init branch Jul 13, 2014
@stevengj stevengj referenced this pull request Nov 7, 2014
Closed

document module __init__ #8923

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.