Named multi-imports

jmh530 via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 16 05:04:13 PDT 2017


On Wednesday, 16 August 2017 at 10:12:01 UTC, Joel Nilsson wrote:
> On Tuesday, 15 August 2017 at 21:12:24 UTC, jmh530 wrote:
>>
>> In the past, I've thought it would be convenient to have 
>> something like
>>
>> import io = std.stdio : writeln, write;
>>
>> and allow someone to write
>>
>> io.write("foo");
>> io.writeln("bar");
>>
>
> This is already in the language: 
> http://dlang.org/spec/module.html#renamed_imports

Well I knew that renamed imports were allowed, but I didn't 
realize you could do re-named selective imports (the " : writeln, 
write" part of it). I just double-checked and it worked. I don't 
recall it working in the past.

I see that there's an example in the spec, but it is a little 
more complicated than my example.


More information about the Digitalmars-d mailing list