scoped imports

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Sat Aug 17 18:16:44 PDT 2013


On Saturday, 17 August 2013 at 22:30:14 UTC, Timothee Cour wrote:
> Is there a way to achieve this:
>
> ----
> module foo;
>
> {
> import bar;
> void fun1(){bar.barfun();}
> void fun2(bar.BarType a){}
> }
>
> // now bar is not in scope anymore.
> void fun3(){}
> ----
>
> This would reduce name clashes conflicts, ease refactorings and 
> in general
> make code a bit cleaner.

Why not import bar _inside_ fun1 and fun2 ... ?

     void fun1()
     {
         import bar;
         barFun();
     }

... should work, no?


More information about the Digitalmars-d-learn mailing list