toUTFz and WinAPI GetTextExtentPoint32W

Jonathan M Davis jmdavisProg at gmx.com
Tue Sep 20 15:25:09 PDT 2011


On Tuesday, September 20, 2011 15:10 Andrej Mitrovic wrote:
> On 9/20/11, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> > We specifically avoid having aliases in Phobos simply for having
> > alternate function names. Aliases need to actually be useful, or they
> > shouldn't be there.
> 
> And function names have to be useful to library users. walkLength is
> an awful name for something that returns the character count.
> 
> If you ask a GUI developer to look for a function that creates a
> rectangle path, you can be sure he'll start looking for Rectangle or
> DrawRect or something similar, and not "ClosedShapePointN!4" or
> something that generic.

In this case, if there's a problem it's not how generic the function is, it's 
the name walkLength. There's nothing special about strings which makes the 
name count better for them than it is for other ranges. The function is 
returning the number of elements in the range - be they code points or 
integers or whatever. The name walkLength works just as well for strings as it 
does for anything else. So, if there's a problem it's that the name walkLength 
isn't necessarily all that great. Strings aren't so special that they merit 
their own function name for the same functionality. So, if count stays, it's 
simply because it's been around for a while, not because it's inherently 
better to have a separate count function.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list