that's not DRY: in my use case, a group of functions use certain imports, it would be annoying and not DRY to do that. What I suggest (allowing {} grouping at module scope) seems simple and intuitive; any reason it can't be done?


On Sat, Aug 17, 2013 at 6:16 PM, Joseph Rushton Wakeling <joseph.wakeling@webdrake.net> wrote:
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?