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

Reorganize the Modules chapter of the manual. #38271

Merged
merged 6 commits into from
Nov 5, 2020

Conversation

tpapp
Copy link
Contributor

@tpapp tpapp commented Nov 2, 2020

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

  • explain namespaces, qualified symbol names, and export lists
  • consolidate examples where applicable
  • fix examples which were outdated after make using A.B only for modules, using A: B only for single bindings #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

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 was reviewed, but is left unchanged.

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.
Copy link
Sponsor Member

@timholy timholy left a 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!

doc/src/manual/modules.md Outdated Show resolved Hide resolved
doc/src/manual/modules.md Outdated Show resolved Hide resolved
doc/src/manual/modules.md Outdated Show resolved Hide resolved
tpapp and others added 3 commits November 2, 2020 14:01
Co-authored-by: Tim Holy <[email protected]>
Co-authored-by: Tim Holy <[email protected]>
@simonbyrne
Copy link
Contributor

Thank you!

@simonbyrne simonbyrne added docs This change adds or pertains to documentation modules labels Nov 5, 2020
@timholy timholy merged commit 9e09f70 into JuliaLang:master Nov 5, 2020
@timholy
Copy link
Sponsor Member

timholy commented Nov 5, 2020

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

What is the semantics of importing a top-level module from a sub-module?
3 participants