DIP61: Add namespaces to D

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 28 06:20:19 PDT 2014


On Mon, 28 Apr 2014 04:10:34 -0400, Andrej Mitrovic via Digitalmars-d  
<digitalmars-d at puremagic.com> wrote:

> 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
> }
> -----

And actually, this would have to be std.clock.currTime  
(std.datetime.clock.currTime?)

What you are looking for is renamed imports.

import std.datetime.clock = clock;

Which cannot be enforced. and that is really the problem.

-Steve


More information about the Digitalmars-d mailing list