std.uni.toLowerCase / .toUpperCase

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 24 06:56:59 PDT 2015


On Wednesday, 24 June 2015 at 13:37:35 UTC, Jacob Carlborg wrote:
> On 24/06/15 07:20, Jonathan M Davis wrote:
>
>> If we want to be consistent with the likes of splitter, then 
>> they should
>> be something more like lowerCaser and upperCaser (though caser 
>> isn't
>> really word, and AFAIK, there is no noun for something which 
>> changes the
>> case of a letter).
>
> How is that consistent? The original names are toLower/toUpper, 
> not lowerCase/upperCase. So it should be something like 
> toLowerer but that clearly doesn't work.

It's consistent with the naming scheme used by functions like 
splitter, joiner, or filter (though in filter's case, it's both a 
verb and a noun). The function is named after the noun that does 
the operation rather than the operation - e.g. the verb is split, 
but the one that does the splitting is the splitter. So, in the 
case of toLower and toUpper, what you're manipulating is the 
case, so following that naming scheme, a lower caser would be 
what did the to lower case operation, and an upper caser would be 
what did the to upper case operation. Now, that's ugly since 
caser isn't a real word (there really isn't a noun for something 
which changes a letter to uppercase or lowercase), but it's 
following the same scheme as splitter. Conversely, we could go 
with lowerer and upperer, though those are pretty ugly and 
nonsensical too, but having to in the name doesn't follow the 
convention that we use with functions like splitter or joiner, so 
toLowerer like you suggest wouldn't fit.

All in all, because there is no noun or object which changes the 
case of letters (it's really just an operation), following the 
naming scheme of functions like splitter is bound to be ugly. But 
it _is_ making them consistent with what we've done with the 
names of existing functions when we've made lazy versions of them 
(e.g. split -> splitter, and join -> joiner).

- Jonathan M Davis


More information about the Digitalmars-d mailing list