toString vs. toUtf8

Julio César Carrascal Urquijo jcarrascal at gmail.com
Tue Nov 20 14:45:38 PST 2007


Gregor Richards wrote:
> Jarrett Billingsley wrote:
>> Do you want to know my single overriding reason for wanting toString 
>> instead of toUtf8?  Because it's nicer-looking and easier to type.
> 
> Hear hear.

Actually, Jarrett's other arguments seemed more compelling to me.

Jarrett Billingsley wrote:
 > My other reasons include consistency (Java uses .toString, .Net uses
 > ..ToString, phobos uses .toString) and that "toUtf8" screams "I'm a 
string
 > class and this method converts my encoding!"  while "toString" says 
"convert
 > this object, whatever it is, to some kind of string."


Stating intent seem more important to me than the stylistic issues 
between toString and toUtf8. I'm all for the toString / toWString / 
toDString for a readable representation of a class and toUtf8 / 16 / 32 
for converting encodings.

Also, toStringW seems more readable than toWString but for me its not 
big of a deal which one Tango developers choose.


-- 
Julio César Carrascal Urquijo
http://jcesar.artelogico.com/



More information about the Digitalmars-d mailing list