Conflict between std.file write() and std.stdio write()

1100110 0b1100110 at gmail.com
Thu Oct 3 11:36:06 PDT 2013


On 10/03/2013 01:11 PM, Jonathan M Davis wrote:
> On Thursday, October 03, 2013 15:22:28 Craig Dillabaugh wrote:
>> It seems that std.file should include a writeText() function for
>> the sake of consistency that is the above alias. When you come
>> across readText() in the documentation you sort of expect that
>> such a function would exist, and then you spot write() below it,
>> and think hey that does what I need. Then you hit upon the
>> syntax error if you are also using std.stdio (which is a very
>> commonly used module).
>>
>> Adding writeText() doesn't really add much to the library, but
>> having to jump through hoops (as minor as they may be) to perform
>> such a simple op is a bit of a pain for people new to the
>> language.
>
> writeText would be redundant. write will already write arbitrary data to a file
> - including strings. writeText would add no functionality. Functions should
> add actual value, or they just clutter up the library.
>
> Conflicting functions is just part of life. The module system is designed to
> let you disambiguate them. We're not going to try and make all of the function
> names unique just because you might import a module with a conflicting
> function. If write is the best name for the function, then that's what we'll
> use, even if it conflicts with a function in another module. To do otherwise
> would be to ignore the features of the module system and force us to come up
> with worse names just to avoid conflicts.
>
> - Jonathan M Davis
>

I *like* the fact I only have to remember one API.
A simple alias or disambiguation every once in a while is well worth it 
IMHO.


More information about the Digitalmars-d-learn mailing list