scoped imports

Timothee Cour thelastmammoth at gmail.com
Sat Aug 17 16:47:09 PDT 2013


thanks.
That's a bit clunky though, so it's unlikely to be used. Not sure what it
would take to make the grammar allow it.


On Sat, Aug 17, 2013 at 4:23 PM, bearophile <bearophileHUGS at lycos.com>wrote:

> Timothee Cour:
>
>
>  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.
>>
>
> Using a struct as namespace:
>
>
> struct Foo {
>     import std.stdio;
>     static void bar(int x) { x.writeln; }
> }
> alias bar = Foo.bar;
>
> void main() {
>     bar(10);
>     // writeln(20); // std.stdio out of scope
> }
>
>
> Bye,
> bearophile
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130817/4781f81a/attachment.html>


More information about the Digitalmars-d-learn mailing list