Language Devel / DIPs /
DIP14
DIP14: Import path binding in source code
|
Abstract
Provide a language construct to declare import paths in source files.
Rationale
Declaring the location of dependencies should be done at the place where the dependency occurs. This reduces redundancy and maintenance effort. This is a requirement for DIP11.
Description
The specification for ImportDeclaration is extended as follows.
|
Usage
|
This will not add a symbol bar to the current scope.
|
Impact
Allowing an expression as module name does conflict with import bindings and alias imports.
|
Alternatives
It was proposed in DIP11 to add a new pragma(importpath, "ImportSpec") with the same rules as giving a command line import path.
This has two drawbacks. First one would need to statements to import a module.
|
Second using a pragma needs scoping rules. It was proposed that pragma(importpath) only be valid for that particular module. This has maintenance issues as every import from that path and the imported source themselves need to be kept in sync. One would need additional means to selectively transfer the import path to other modules.
Copyright
This document has been placed in the Public Domain.