Why invariants in D 2.0 std.string?

Bill Baxter dnewsgroup at billbaxter.com
Wed Oct 31 14:53:01 PDT 2007


Janice Caron wrote:

> That's cool. It works for any kind of string. But the pre-existing
> functions are still chars only. For example, tolower is still:
>     invariant(char)[] tolower(invariant(char)[] s)
> 
> instead of, as one might hope:
>     S tolower(S)(S s)


I agree it would be nice if they worked for other string types, but I 
would regret the loss of clarity in the signature.
char[] tolower(char[] s) tells you immediately what you can pass to it, 
but S tolower(S)(S s) tells you absolutely nothing about what the legal 
inputs are.

--bb



More information about the Digitalmars-d mailing list