Conflict between std.file write() and std.stdio write()
Craig Dillabaugh
cdillaba at cg.scs.carleton.ca
Wed Oct 2 17:42:55 PDT 2013
On Thursday, 3 October 2013 at 00:04:31 UTC, Jonathan M Davis
wrote:
> On Thursday, October 03, 2013 01:39:38 Craig Dillabaugh wrote:
>> Hello,
>> I have the following program:
>>
>> import std.file;
>> import std.stdio;
>>
>> void main( string[] args ) {
>> string str = "Hello";
>> write( "file.txt", str );
>>
>> string hello_file = readText("file.txt");
>>
>> writeln( hello_file );
>> }
>>
>> When I try to compile this I get:
>>
>> test.d(6): Error: std.stdio.write!(string, string).write at
>> /usr/include/dmd/phobos/std/stdio.d(1656) conflicts with
>> std.file.write at /usr/include/dmd/phobos/std/file.d(318)
>>
>> I think this should work. The example at the end of (D file
>> I/0):
>>
>> http://www.docwiki.net/view.php?pageid=145
>>
>> Uses write() exactly the way I am using it here.
>
> You have to give the full path - std.file.write. As both
> functions can take the
> same arguments, and you've imported both, the compiler has no
> way of knowing
> which you mean. So, you have to disambiguate for it. It's only
> a problem
> because you imported both modules.
>
> - Jonathan M Davis
Thanks. Seems kind of an odd design decision (or oversight) that
two commonly used functions in the standard library would clash
in this manner, but I guess it is no big deal.
Cheers,
Craig
More information about the Digitalmars-d-learn
mailing list