toString issue

Chris Nicholson-Sauls ibisbasenji at gmail.com
Sat Sep 30 08:50:38 PDT 2006


Sean Kelly wrote:
> Johan Granberg wrote:
> 
>> As a result of the discussion about char[] above I have been 
>> converting some of my code from dchar[] to char[], but that reminded 
>> me of an issue i have with the current state of phobos. in object 
>> their is the method toString that happened to have the same name as 
>> the COMMONLY used function std.string.toString this causes objects 
>> toString to shadow std.strings to string inside class methods. I know 
>> that FQN can be used as a workaround but it makes the code unnecessary 
>> hard to read and I think that name clashes such as this should be 
>> avoided in the standard library.
>>
>> PROPOSAL. change all methods in object to have some prefix for to 
>> string I suggest opString as the op prefix is already in use.
> 
> 
> How about toUtf8() for classes and structs :-)
> 
> 
> Sean

Gets my vote.  Note that Mango classes typically already do this (with toString just 
calling toUtf8 in most cases), and provide toUtf16/toUtf32 counterparts.  It is indeed 
effective.  :)

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list