std.uni.toLowerCase / .toUpperCase

Mike via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 23 17:17:51 PDT 2015


On Tuesday, 23 June 2015 at 23:58:52 UTC, Vladimir Panteleev 
wrote:
> On Tuesday, 23 June 2015 at 23:49:45 UTC, Vladimir Panteleev 
> wrote:
>> - Ultimately, we want to encourage use of the lazy versions, 
>> in the same way that e.g. std.algorithm and std.range are 
>> encouraged over eager operations for arrays.
>
> Another point: the range-ification of Phobos is only going to 
> continue. This means that, should this scheme be followed, the 
> number of functions with "Lazy" in the same is only going to 
> grow, and as these functions are intended to become the 
> canonical way to write modern D, so will the number of 
> occurrences of "Lazy" in a typical canonical D program. I think 
> this is a strong argument for avoiding "Lazy", at least for 
> functions which intend to displace their eager counterparts.

Ok, I'm with you.  Allow me to offer another suggestion then.

1. Add functions `toUpperCaseEager` and `toLowerCaseEager`.
2. Have `toUpper` forward to `toUpperCaseEager` and `toLower` 
forward to `toLowerCaseEager` with a friendly comment.  You don't 
need to deprecate `toUpper` or `toLower` unless you want to.  It 
will happen naturally and gradually in time anyway.
3. Add functions `toUpperCase` and `toLowerCase` implementing the 
lazy versions.

Something similar could also be applied to `setExtension`
1. Add `setExt` implementing the lazy version and `setExtEager` 
implementing the eager version
2. Forward `setExtension` to `setExtEager` with a friendly 
comment.  Again, you don't need to deprecate `setExtension` 
unless you want to.  It will happen naturally and gradually in 
time anyway.

If this only makes things worse in your opinion, go with 
`withExtension` and your other suggestions.  I'm already weary of 
this.

Mike


More information about the Digitalmars-d mailing list