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

Export FQN without any imports #9562

Closed
2 of 3 tasks
JaroslavTulach opened this issue Mar 27, 2024 · 3 comments · Fixed by #9683
Closed
2 of 3 tasks

Export FQN without any imports #9562

JaroslavTulach opened this issue Mar 27, 2024 · 3 comments · Fixed by #9683
Assignees

Comments

@JaroslavTulach
Copy link
Member

JaroslavTulach commented Mar 27, 2024

The import/export documentation has been incorrectly understood leading to an obscure, verbose, do repeat yourself usages polluting all our standard libraries.

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.

The only name brought into scope by such an export is the name of the module (or the name provided after the as keyword, if provided).

For a while I am puzzled, by our usual code that imports and exports at once:

import project.System.Platform
export project.System.Platform

as shown for example in here. It is not really DRY, right?

Reading the Qualified Exports section, I believe the specification actually says that we should be able to do just:

export project.System.Platform

There's no point to import FQN and export FQN. Let's not spell FQN twice! Alternatively one could write:

import project.System.Platform
export Platform

that'd also logical and rationalistic. But the current use of doubled FQN in export and import is just unnecessary boilerplate.

Tasks

@enso-bot
Copy link

enso-bot bot commented Apr 11, 2024

Pavel Marek reports a new STANDUP for today (2024-04-11):

Progress: - Tweaked the import/export resolver to insert synthetic imports in certain cases.

  • Removed all unnecessary imports from all Main modules accross the codebase. It should be finished by 2024-04-16.

@JaroslavTulach
Copy link
Member Author

The #9683 PR fixes all but "Support import ... followed by simple non-qualified export Platform" (low priority) task, right?

@Akirathan
Copy link
Member

The #9683 PR fixes all but "Support import ... followed by simple non-qualified export Platform" (low priority) task, right?

@JaroslavTulach No. The following snippet:

import project.Mod.Type
export Type

Results in a compilation error:

Execution finished with an error: org.enso.compiler.core.CompilerError: Compiler Internal Error: Imports should contain at least two segments after desugaring.
        at <java> org.enso.runtime/org.enso.compiler.phase.ImportResolverAlgorithm.tryResolveImportNew(ImportResolverAlgorithm.java:136)
        at <java> org.enso.runtime/org.enso.compiler.phase.ImportResolverAlgorithm.tryResolveImport(ImportResolverAlgorithm.java:72)
        at <java> org.enso.runtime/org.enso.compiler.phase.ImportResolver.$anonfun$addSyntheticImports$2(ImportResolver.scala:205)
        at <java> org.enso.runtime/scala.collection.immutable.List.flatMap(List.scala:293)
        at <java> org.enso.runtime/org.enso.compiler.phase.ImportResolver.addSyntheticImports(ImportResolver.scala:179)
        at <java> org.enso.runtime/org.enso.compiler.phase.ImportResolver.analyzeModule$1(ImportResolver.scala:80)
        at <java> org.enso.runtime/org.enso.compiler.phase.ImportResolver.go$1(ImportResolver.scala:145)
        at <java> org.enso.runtime/org.enso.compiler.phase.ImportResolver.mapImports(ImportResolver.scala:161)
        at <java> org.enso.runtime/org.enso.compiler.Compiler.liftedTree1$1(Compiler.scala:457)
        at <java> org.enso.runtime/org.enso.compiler.Compiler.runImportsAndExportsResolution(Compiler.scala:456)
        at <java> org.enso.runtime/org.enso.compiler.Compiler.$anonfun$runCompilerPipeline$2(Compiler.scala:274)
        at <java> org.enso.runtime/scala.collection.immutable.List.flatMap(List.scala:293)
        at <java> org.enso.runtime/org.enso.compiler.Compiler.runCompilerPipeline(Compiler.scala:269)
        at <java> org.enso.runtime/org.enso.compiler.Compiler.go$1(Compiler.scala:234)
        at <java> org.enso.runtime/org.enso.compiler.Compiler.runInternal(Compiler.scala:241)
        at <java> org.enso.runtime/org.enso.compiler.Compiler.run(Compiler.scala:132)

Theoretically, it should work. But since we already support only exports without imports, I don't see any added value to this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🟢 Accepted
Development

Successfully merging a pull request may close this issue.

2 participants