Language Devel / DIPs /
DIP15
Difference (last change) (Author, normal page display)
Added: 73a74,77
import pkg.a; // ok will import root/pkg/a.d // this is equivalent to import pkg._; |
Added: 85a90,94
import pkg.a; // ok will import root/pkg/a.d // pkg is the package with merged in scope of pkg._ // this has no direct equivalence but is roughly static import pkg = pkg._; |
Added: 97a107,111
import util.a; // ok will import root/pkg/a.d // util is the package pkg with merged in scope of pkg._ // this has no direct equivalence but is roughly import util = pkg._; |
Added: 106a121,124
// this is equivalent to static import __hidden = pkg._; import pkg.b; |
DIP15: Import of packages
|
Abstract
Provide means to import a whole package.
Rationale
A way of importing a package is proposed. This provides finer grained control of organizing packages and submodules and simplifies their usage. It will further allow to decouple a package's interface from it's internal organization.
Description
An import that does not resolve to a D source file but to a directory that has a _.{d|di} file will be treated as a package import.
Given the following files.
root
|--- pkg |--- _.d
|
|--- a.d
|
|--- b.d
|
The following behaviors are proposed.
Package import.
|
Static package import.
|
Aliasing the package.
|
Qualified import of submodule.
|
Any of the these will execute the static initializer of pkg._.
Impact
The idiom of explicitly importing _.d is already used. This will not conflict with existing code as it is either an error now or doesn't change the scope members.
Copyright
This document has been placed in the Public Domain.