-
Notifications
You must be signed in to change notification settings - Fork 70
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
introduce import and export statements #1453
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
Change in memory usage detected by benchmark. Memory Report for bc22eb7
|
Benchmark for bc22eb7Click to view benchmark
|
Co-authored-by: Mine Starks <16928427+minestarks@users.noreply.github.com>
_branched off of #1469_ This PR mainly introduces glob imports in import statements, e.g.: ``` import Foo.*; import Foo.Bar.* as Baz; ``` et cetera. Glob imports work similarly to other languages: `Foo.*` brings in everything from `Foo`, while `Foo.* as Bar` brings in all of `Foo`, but aliased under a namespace `Bar`. For example, if `function F() : Unit {}` exists in `Foo`, then after importing via `Foo.* as Bar`, it would be available as `Bar.F()`. Other incidental changes include: - Improving the `Display` impl for `ImportOrExportItem`, for easier-to-read tests
minestarks
approved these changes
Jun 6, 2024
Change in memory usage detected by benchmark. Memory Report for aee8f6d
|
Benchmark for aee8f6dClick to view benchmark
|
Change in memory usage detected by benchmark. Memory Report for 1f2af71
|
Benchmark for 1f2af71Click to view benchmark
|
swernli
reviewed
Jun 11, 2024
Change in memory usage detected by benchmark. Memory Report for 171a565
|
Benchmark for 171a565Click to view benchmark
|
swernli
approved these changes
Jun 11, 2024
…rt visibility is enforced
sezna
force-pushed
the
alex/export-statements
branch
from
June 11, 2024 19:59
82ef114
to
21d2db6
Compare
Change in memory usage detected by benchmark. Memory Report for 2119ad9
|
Benchmark for 2119ad9Click to view benchmark
|
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.
This PR introduces exports and imports. A namespace can export any symbol it has access to. External packages (consumers of this package) will only have access to explicitly exported items.
How it works
Exports are a type of
Item
, and they appear inside of namespaces (implicit or explicit). Exports are paths, which are resolved to local item ids in the resolver. They are then bound to the scope of that namespace. After that, the exported item is added to the api surface of the namespace.When we support external package dependencies, we only want to allow importing of explicitly exported items. At that time, we will add a flag to the items to denote if they originate from an export.
This PR also supports export aliases:
export Foo as Bar;
Glob imports work similarly to other languages:
Foo.*
brings in everything fromFoo
, whileFoo.* as Bar
brings in all ofFoo
, but aliased under a namespaceBar
. For example, iffunction F() : Unit {}
exists inFoo
, then after importing viaFoo.* as Bar
, it would be available asBar.F()
.