Introduce export keyword for cross-module item visibility#29542
Open
IGI-111 wants to merge 4 commits into
Open
Introduce export keyword for cross-module item visibility#29542IGI-111 wants to merge 4 commits into
export keyword for cross-module item visibility#29542IGI-111 wants to merge 4 commits into
Conversation
9c49c94 to
5e1b102
Compare
Module-level `fn`, `struct`, `const`, and `interface` declarations now accept an `export` modifier, which is mandatory to make them reachable from other source files or compilation units. Items inside a `program` block cannot be qualified with `export` since they are already implicitly public. Accessibility rules are checked in the type checking phase. This is a breaking change, as previously unqualified function declarations are now private by default. `export` was chosen instead of `pub` because: 1. it is desirable to minimize confusion with existing and future uses of `public`/`private` 2. access rules are more analog to Javascript than Rust (no `mod`, relative paths) 3. we already have an `import` keyword
This file contains hidden or 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
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.
Module-level
fn,struct,const, andinterfacedeclarations now accept anexportmodifier, which is mandatory to make them reachable from other source files or compilation units.Items inside a
programblock cannot be qualified withexportsince they are already implicitly public.Accessibility rules are checked in the type checking phase.
This is a breaking change, as previously unqualified function declarations are now private by default.
exportwas chosen instead ofpubbecause:public/privatemod, relative paths)importkeyword