-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Reorganize the Modules chapter of the manual. #38271
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Main changes Namespaces, export, import, using - explain namespaces, qualified symbol names, and export lists - consolidate examples where applicable - fix examples which were outdated after JuliaLang#25306 - distribute the “Namespace miscellanea” section into parts in the appropriate sections - break up the summary table and explain each case in detail with examples - subsection on various strategies to handle symbol conflicts - use “bring into the namespace/scope” instead of “import” in the text, as readers confuse it with `import` - explicitly document what happens with multiple `using` / `import` statements - add relevant style / best practices suggestions which are now widely used in the Julia ecosystem Submodules - discuss usage of `using ParentModule.SubModule` etc (relies on code loading) - add submodule examples where order matters, fixes JuliaLang#38011 (also another example by @rdeits [from Discourse](https://discourse.julialang.org/t/problem-with-using-in-submodules/42321/2)) - mention that submodules do not “inherit” scope from parent Misc incidental changes - in the Methods chapter, add a note about adding methods to functions in other modules - add a markdown id to the code-loading chapter The “Module initialization and precompilation” section is left unchanged.
timholy
reviewed
Nov 2, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks for doing this!
Co-authored-by: Tim Holy <tim.holy@gmail.com>
Co-authored-by: Tim Holy <tim.holy@gmail.com>
Co-authored-by: Tim Holy <tim.holy@gmail.com>
simonbyrne
reviewed
Nov 4, 2020
simonbyrne
reviewed
Nov 4, 2020
Thank you! |
remove whitespace Co-authored-by: Simon Byrne <simonbyrne@gmail.com>
simonbyrne
approved these changes
Nov 5, 2020
Awesome, thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Many users, especially from languages which either don't have namespaces or do not use them widely, are confused by various aspects of Julia's namespace management. This is a reorganization (and partial rewrite) or the relevant chapter, with the intention that it should tide us over until (if) breaking changes like #8000 happen.
I have searched the issues and the Discourse forum for related topics and tried to address every issue that comes up in a concise but occasionally introductory/pedagogical manner, going into details and corner cases when relevant after conveying the main idea. Each particular change/addition was motivated by people running into problems with some feature. I combined and modified examples from various contributors, and only reference the original when I use it unchanged.
Since this is a substantial rewrite, thorough reviews would be appreciated. If, despite best effort, I missed some commonly used scenarios or made mistakes, please comment and I am happy to address them.
Main changes
Namespaces,
export
,import
,using
using A.B
only for modules,using A: B
only for single bindings #25306import
using
/import
statementsSubmodules
using ParentModule.SubModule
etc (relies on code loading)Misc incidental changes
The “Module initialization and precompilation” section was reviewed, but is left unchanged.