Skip to content

Dart imports system #30299

Closed as not planned
Closed as not planned
@JFixby

Description

@JFixby

Hello,

I just want to put in my two cents on the issue and document this concerns about code imports in Dart.
I don't expect anyone to take it seriously. I totally understand the issue has the lowest priority and I apologise for any inconvenience caused.

Designing imports system makes sense to take in account Java. The language has a very powerful imports management with a very simple and reliable syntax.

Example:

import com.company.libraby.package.Class;
  1. That namespace is wider than the intended language. Import refers to concept in a knowledge domain, not to a specific class. Since no files are mentioned in the import the naming works outside Java language.
  2. Import syntax has no references to a project name (in contrary to the Dart). Client code doesn't know and doesn't care about the source if the import. The client delegates the responsibility of providing its dependencies to external system like IDE or a runtime environment.
  3. Name conflicts are resolved using explicit import. If you have a class that refers to the Map interface and some other geographical Map, you can call classes with their full names like com.java.util.Map and org.geography.Map. No need obscuring your code with import A as B-type statements.

Here I documented some of the most obvious import refactoring problems I encountered (let me know if you have any workarounds.):
#30294
#30295
#30296
#30297
#30298

All of the mentioned problems are nicely solved in Eclipse IDE for Java developers. So there is proven track record of success for the naming convention.

Key points of it's success:

  1. All public classes are exported by default. No need the export operator.
  2. When you move classes between projects you no need to do refactoring at all. (solves Moving code from one package to another doesn't update dependencies #30298)
  3. IDE takes the job of automatic imports resolution (helps to solve Missing import suggestions #30295 Imports refactoring: changing import folder fails to update dependent classes #30294 Optimize imports command doesn't resolve imports automatically #30296 Dependent project can't see ext imports to make suggestions #30297)

Thank you for your attention to this matter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-staleClosed as the issue or PR is assumed staletype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions