import strangeness with std.stdio.write

bauss jj_1337 at live.dk
Tue Feb 13 14:21:31 UTC 2018


On Tuesday, 13 February 2018 at 13:56:17 UTC, psychoticRabbit 
wrote:
> On Tuesday, 13 February 2018 at 13:52:37 UTC, rikki cattermole 
> wrote:
>> On 13/02/2018 1:46 PM, 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");
>>> }
>>> -----------------------
>>
>> write exists in both, writeln exists only in std.stdio.
>>
>> Use named imports to pick which write you want.
>
> oh..you must have posted as I why posting ;-)
>
> That makes sense then. Thanks for clearing that up.
>
> And I should have read the compiler message more clearly..cause 
> the answer was in that error message (more or less)

What you can do is use aliases to use both functions.

import io = std.stdio;

void main()
{
     import file = std.file;

     file.write("hello");
     io.writeln("hello again");
}


More information about the Digitalmars-d-learn mailing list