Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modules aren't visible until after __init__ finishes #23915

Closed
timholy opened this issue Sep 28, 2017 · 2 comments
Closed

Modules aren't visible until after __init__ finishes #23915

timholy opened this issue Sep 28, 2017 · 2 comments
Labels

Comments

@timholy
Copy link
Member

timholy commented Sep 28, 2017

#23579 changed how modules are loaded. I thought it best to file #23579 (comment) as an issue. The reason turned out to be that #23579 changed behavior of when the module becomes "visible": it used to be that you could refer to the module from outside code that got called via __init__ or one of the registered Base.package_callbacks. Now you have to defer such references until after __init__ finishes.

Code example at timholy/Revise.jl#48 (only the first commit). This new behavior might be intended, in which case please close this issue.

@JeffBezanson
Copy link
Member

The change is intentional. In the new way of doing things, top-level modules don't have Main as their parent module. Since Main is no longer special, assigning X to its module after using X in Main is the last step (the same as in all other modules).

Looking up a top-level module can be done with Base.root_module(name) and replacing one can be done with Base.register_root_module(name, mod).

@timholy
Copy link
Member Author

timholy commented Sep 28, 2017

Thanks, now I understand #23579 a bit better. I attributed the timing issue to be separate, but now it makes much more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants