DIP61: Add namespaces to D
Andrej Mitrovic via Digitalmars-d
digitalmars-d at puremagic.com
Mon Apr 28 01:10:34 PDT 2014
On 4/27/14, Walter Bright via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
> When you find yourself doing things like that, seriously consider creating a
> new
> module to do it, called "clock".
That's not reliable, because static imports are not enforced. It means
anyone importing a module "clock" will automatically have all symbols
in "clock" imported into the current module, meaning this will work:
-----
import clock;
void main()
{
auto time = currTime(); // note the lack of full qualification
}
-----
std.datetime rightly tries to discourage symbol pollution by default
(it has a lot of symbols to begin with). So you're forced to write:
-----
import std.datetime;
void main()
{
auto time = Clock.currTime();
}
-----
> Using smaller modules under packages is a much better way.
Sorry, but this is currently impossible. Programmers will always use
the feature that actually works over a feature that might work some
day. Modules have too many open bugs right now, such as leaking
selective imports, private visibility, non-propagating package access,
etc etc.
If you ever try to build a larger library you'll immediately become
aware of these issues.
More information about the Digitalmars-d
mailing list