Named multi-imports

aberba via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 17 14:03:33 PDT 2017


On Wednesday, 16 August 2017 at 13:57:17 UTC, jmh530 wrote:
> On Wednesday, 16 August 2017 at 09:54:41 UTC, aberba wrote:
>>
>> This looks really clean for code modularity.
>>
>> import io = std.stdio : {writeln, write}, ...
>
> What does this add? A line like below would be confusing.
> import io = std.stdio : {writeln, write}, writefln;
>
> The following code compiles and the imports are less confusing.
>
> import io = std.stdio : writeln, write;
> import std.stdio : writefln;
>
> void main()
> {
>     io.write("foo");
>     io.writeln("bar");
>     writefln("My items are %(%s %).", [1,2,3]);
> }

Its more like this:

import oo = {std.stdio : {writeln, write}, std.algorithm: 
{filter, map}, …};

oo.writeln();
oo.write();
oo.filter(...);
oo.map(...);



More information about the Digitalmars-d mailing list