filtered imports

Jonathan Marler johnnymarler at gmail.com
Thu Sep 13 22:15:44 UTC 2018


On Thursday, 13 September 2018 at 17:54:03 UTC, Vladimir 
Panteleev wrote:
> On Thursday, 13 September 2018 at 16:23:21 UTC, Jonathan Marler 
> wrote:
>> The immediate example is to resolve symbol conflicts.
>
> I've ran into this a few times:
>
> import std.stdio;
> import std.file;
>
> void main(string[] args)
> {
> 	auto text = readText(args[1]);
> 	write("The contents of the file is: ", text);
> }
>
> However, it is solved with an alias:
>
> alias write = std.stdio.write;
>
> (or using selective imports or fully-qualified identifiers for 
> either module of course).

That's pretty slick. I guess I'm all out of use cases then.  I 
did learn a new trick though :)


More information about the Digitalmars-d mailing list