toString vs. toUtf8

Christopher Wright dhasenan at gmail.com
Tue Nov 20 18:40:14 PST 2007


Bill Baxter wrote:
> Christopher Wright wrote:
>> Bill Baxter wrote:
>>> Sean Kelly wrote:
>>>> As an alternative, I can only suggest that toUTF8, toUTF16, and 
>>>> toUTF32 be named toString, toWString, and toDString, respectively, 
>>>> and Unicode should be assumed as the standard encoding format in D.
>>>
>>> 1) On the question of toWString vs toWstring and consistency:
>>>
>>> I don't think there's any clear precedent for either in Tango right 
>>> now, but my question is, if tango *had* a "to uint" function, what 
>>> would it be named?  toUInt or toUint?  Whatever the answer to that is 
>>> should be the same as the answer to how to name a "to wstring" function.
>>
>> If it had a to uint function and a to int function and a to 'sint' 
>> function, what then? If it's only uint, then you can tell the 
>> difference quite easily.
> 
> I don't understand you.  Tell the difference between what?

Sorry, mistyped. If it were 'to uint' and 'to int', that would be rather 
clear. 'to uint' and 'to sint' would be less clear, since they're the 
same number of letters and would have the same capitalization pattern.

>> Also, 'int' is shorter than 'string'. Not a very good comparison.
> 
> What does length have to do with whether or not the naming scheme is 
> consistent?

Readability. I'd rather sacrifice a bit of consistency -- I can memorize 
a *few* inconsistencies -- for readability, whose lack will cause more 
trouble in the future.

With shorter identifiers, smaller differences are more noticeable, but 
'toWString' is a relatively long identifier.

> --bb



More information about the Digitalmars-d mailing list