Nested public imports - bug or feature?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 19 16:25:54 PDT 2015


On 8/13/2015 6:12 AM, Dicebot wrote:
> Right now this works:
>
> ``D
> struct Std
> {
>    public import std.stdio;
> }
>
> void main()
> {
>    Std.writeln("Nice!");
> }
> ```
>
> I want to use it as an import hygiene idiom but not entirely sure if this
> behavior can be relied upon (or it is just a side effect of imports being
> implemented as aliases currently).

It has nothing to do with aliases.

Imports work the same way as template mixins do. They share the same 
implementation code.

Since the import is qualified with 'public', I see no reason to change this 
behavior.


More information about the Digitalmars-d mailing list