import strangeness with std.stdio.write
ketmar
ketmar at ketmar.no-ip.org
Tue Feb 13 13:57:38 UTC 2018
psychoticRabbit wrote:
> So, strange problem below.
>
> The commented-out line will not compile (if I un-comment it), unless I
> either move std.stdio into main, or, move std.file out of main.
>
> Whereas writeln works just fine as is.
>
> ---------------------
> module test;
>
> import std.stdio;
>
> void main()
> {
> import std.file;
>
> //write("hello");
> writeln("hello again");
> }
> -----------------------
`std.file` has function named `write()` too. and local import completely
shadows global imports (i.e. it removes global imports from overload set
for the given scope), hence `std.stdio.write()` is not available there.
this is done by purpose, so your code won't accidentally use wrong
function. you can bring `std.stdio` functions back by adding local `import
std.stdio;`, for example.
More information about the Digitalmars-d-learn
mailing list