toString vs. toUtf8

Chad J gamerChad at _spamIsBad_gmail.com
Tue Nov 20 08:53:43 PST 2007


Kris wrote:
> "Sean Kelly" <sean at f4.ca> wrote in message
> [snip]
>>> Don't know if that hurts your eyes less or not, but it seems more 
>>> consistent with Tango's existing naming convention to me than toWString, 
>>> etc.
>> Yeah I was thinking the same thing.  It's certainly easier for me to read 
>> than the other form.
> 
> 
> Bill: actually, toString, toStringW and toStringD are more consistent with 
> themselves, and with Tango convention. Even toString, toString16 and 
> toString32 are significantly more style-consistent than toWString and 
> toWstring 
> 
> 

This conversation caught my eye and I cringed at toWString and 
toDString.  toStringW and toStringD are acceptable though.

Sean made a brief argument from psychology earlier.  It made me remember 
this thing:

Olny srmat poelpe can raed tihs.

I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. 
The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at 
Cmabrigde Uinervtisy, it deosn’t mttaer in waht oredr the ltteers in a 
wrod are, the olny iprmoatnt tihng is taht the frist and lsat ltteer be 
in the rghit pclae. The rset can be a taotl mses and you can sitll raed 
it wouthit a porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey 
lteter by istlef, but the wrod as a wlohe. Amzanig huh? yaeh and I 
awlyas tghuhot slpeling was ipmorantt!



Perhaps this is important for naming conventions in general?  Any 
similarly named entities must differ at the beginning or end of the 
name.  I'm not sure how deeply this affects existing APIs or if it 
causes problems ;)

It is also noteworthy that char, wchar, dchar are consistent with that 
naming constraint, but not with toStringW and toStringD. IMO the former 
matters more than the latter, simply because it is ingrained into our 
minds.  Still, I am not entirely convinced that such a constraint is 
wise in general, though I do like its application here.



More information about the Digitalmars-d mailing list