-
Notifications
You must be signed in to change notification settings - Fork 323
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
Export works without import #9683
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b599ba7
Update docs of imports
Akirathan 18e5006
ImportResolver tries to add and resolve synthetic imports
Akirathan 9df4873
Add some docs
Akirathan 3d7cd8b
syntheticImports are tracked by name
Akirathan a7dd1a5
Add some tests
Akirathan a43cce8
syntheticImports are not generated when module exports from itself
Akirathan 62ff192
fmt
Akirathan ecb2e37
Mention "export without import" in the docs
Akirathan d713451
Remove imports from Standard.Base.Main
Akirathan c51f26f
Remove imports from other Main modules in std libs
Akirathan b0e5c87
Remove imports from Boolean module
Akirathan b31471d
Remove imports from Standard.Visualization.Main
Akirathan 9789bc1
Remove imports from test-micro-distribution Main module
Akirathan 13ad805
Remove unecessary imports from other test Main modules
Akirathan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
17 changes: 0 additions & 17 deletions
17
distribution/lib/Standard/Database/0.0.0-dev/src/Main.enso
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
import project.Snowflake_Details.Snowflake_Details | ||
export project.Snowflake_Details.Snowflake_Details |
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
6 changes: 0 additions & 6 deletions
6
distribution/lib/Standard/Visualization/0.0.0-dev/src/Main.enso
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,40 +27,50 @@ code from modules. | |
|
||
## Qualified Names | ||
|
||
Both imports and exports require the use of qualified module names. A qualified | ||
In the following text, **entity** shall denote a module, a method (instance, | ||
static, foreign), type, or a type constructor. In other words, an _entity_ is | ||
anything that can be assigned to a variable. | ||
|
||
Both imports and exports require the use of qualified entity names. A qualified | ||
name consists of the library namespace (usually organization under which its | ||
published) and the library name, followed by module names mirroring the source | ||
tree of the library. For example the file `src/Stuff/Things/Util.enso` inside | ||
the library `My_Lib` published by the user `wdanilo` would have the following | ||
qualified name: `wdanilo.My_Lib.Stuff.Things.Util`. To facilitate library | ||
renaming (or deciding on the publishing organization later in the development | ||
cycle, or working on a project that won't be published) it is possible to use | ||
the keyword `project` instead of namespace and project name, to import a file in | ||
the same project. Therefore, the file `src/Varia/Tools/Manager.enso` in `My_Lib` | ||
published (or not) by `wdanilo` may use `project.Stuff.Things.Util` to refer to | ||
the previously mentioned file. | ||
tree of the library, followed by an entity name within that module. For example | ||
the file `src/Stuff/Things/Util.enso` inside the library `My_Lib` published by | ||
the user `wdanilo` would have the following qualified name: | ||
`wdanilo.My_Lib.Stuff.Things.Util` and the type `My_Type` within that module | ||
would have the qualified name `wdanilo.My_Lib.Stuff.Things.Util.My_Type`. To | ||
facilitate library renaming (or deciding on the publishing organization later in | ||
the development cycle, or working on a project that won't be published) it is | ||
possible to use the keyword `project` instead of namespace and project name, to | ||
import a file in the same project. Therefore, the file | ||
`src/Varia/Tools/Manager.enso` in `My_Lib` published (or not) by `wdanilo` may | ||
use `project.Stuff.Things.Util` to refer to the previously mentioned file. | ||
|
||
Currently, the `project` keyword works only in import and export statements. | ||
Note that it is possible to export a symbol from the current project with the | ||
`project` keyword without first importing it. | ||
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes in this PR are mentioned just in this paragraph. The rest of the diff to this documentation file is just an attempt to update the specification to correspond to the current functionality. |
||
|
||
## Import Syntax | ||
|
||
There are two main ways of importing a module into the current scope. | ||
|
||
### Qualified Imports | ||
|
||
These imports consist of the word `import` followed by a qualified name of a | ||
module. This can by optionally followed by the `as` word, and a referent name of | ||
the module as it should be visible in the importing scope. | ||
These imports consist of the word `import` followed by a qualified name of an | ||
entity. This can be optionally followed by the `as` word, and a referent name of | ||
the entity as it should be visible in the importing scope. | ||
|
||
The only name brought into scope by such an import is the name of the module (or | ||
The only name brought into scope by such an import is the name of the entity (or | ||
the name provided after the `as` keyword, if provided). | ||
|
||
### Unqualified Imports | ||
|
||
Unqualified imports are broken up into three main categories: | ||
|
||
1. **Unrestricted Imports:** These import all symbols from the module into the | ||
current scope. They consist of the keyword `from`, followed by a qualified | ||
module name, followed by an optional rename part (using the `as` keyword), | ||
then the keywords `import all`. For example: | ||
1. **Unrestricted Imports:** These import all symbols (entities) from the module | ||
(or from a type) into the current scope. They consist of the keyword `from`, | ||
followed by a qualified module name, followed by an optional rename part | ||
(using the `as` keyword), then the keywords `import all`. For example: | ||
``` | ||
from Standard.Base.Data.List as Builtin_List import all | ||
``` | ||
|
@@ -81,8 +91,9 @@ Unqualified imports are broken up into three main categories: | |
from Standard.Base.Data.List import all hiding Cons, Nil | ||
``` | ||
|
||
Imports in Enso _may_ introduce ambiguous symbols, but this is not an error | ||
until one of the ambiguous symbols is _used_ in Enso code. | ||
Imports in Enso _may_ introduce ambiguous symbols, which is treated as a | ||
compilation error. Ideally, the error should be delayed until one of the | ||
ambiguous symbols is _used_ in Enso code. | ||
|
||
## Export Syntax | ||
|
||
|
@@ -92,44 +103,44 @@ appear in Enso as follows: | |
|
||
### Qualified Exports | ||
|
||
These exports consist of the word `export` followed by a qualified name of a | ||
module. This can by optionally followed by the `as` word, and a referent name of | ||
the module as it should be visible in the exporting scope. | ||
These exports consist of the word `export` followed by a qualified name of an | ||
entity. This can be optionally followed by the `as` word, and a referent name of | ||
the entity as it should be visible in the exporting scope. | ||
|
||
The only name brought into scope by such an export is the name of the module (or | ||
The only name brought into scope by such an export is the name of the entity (or | ||
the name provided after the `as` keyword, if provided). | ||
|
||
### Unqualified Exports | ||
|
||
Unqualified exports are broken up into three main categories: | ||
|
||
1. **Unrestricted Exports:** These export all symbols from the module into the | ||
current scope. They consist of the keyword `from`, followed by a qualified | ||
module name, followed by an optional rename part (using the `as` keyword), | ||
then the keywords `export all`. For example: | ||
1. **Unrestricted Exports:** These export all symbols from the module or type | ||
into the current scope. They consist of the keyword `from`, followed by a | ||
qualified module name, followed by an optional rename part (using the `as` | ||
keyword), then the keywords `export all`. For example: | ||
``` | ||
from Standard.Base.Data.List as Builtin_List export all | ||
``` | ||
2. **Restricted Exports:** These export a specified set of names, behaving as | ||
though they were redefined in the current scope. They consist of the keyword | ||
`from`, followed by a qualified module name (with optional `as`-rename), then | ||
the word `export` followed by a coma-separated list of names to be exported. | ||
For example: | ||
`from`, followed by a qualified module or type name (with optional | ||
`as`-rename), then the word `export` followed by a coma-separated list of | ||
names to be exported. For example: | ||
``` | ||
from Standard.Base.Data.List export Cons, Nil, from_vector | ||
``` | ||
3. **Hiding Exports:** These are the inverse of restricted exports, and export | ||
_all_ symbols other than the named ones. They consist of the `from` keyword, | ||
followed by a qualified module name (with optional `as`-rename), then the | ||
words `export all hiding`, followed by a coma-separated list of names to be | ||
excluded from the export. For example: | ||
followed by a qualified module or type name (with optional `as`-rename), then | ||
the words `export all hiding`, followed by a coma-separated list of names to | ||
be excluded from the export. For example: | ||
``` | ||
from Standard.Base.Data.List export all hiding from_vector, Nil | ||
``` | ||
|
||
In essence, an export allows the user to "paste" the contents of the module | ||
being exported into the module declaring the export. This means that exports | ||
that create name clashes must be resolved at the _export_ site. | ||
In essence, an export allows the user to "paste" the contents of the module or | ||
type being exported into the module declaring the export. This means that | ||
exports that create name clashes must be resolved at the _export_ site. | ||
|
||
### Visibility of Export Bindings | ||
|
||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
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 a very nice change!