scoped imports
Timothee Cour
thelastmammoth at gmail.com
Sat Aug 17 18:33:37 PDT 2013
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 at 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?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130817/04012f34/attachment.html>
More information about the Digitalmars-d-learn
mailing list