Statically forbid string ~ size_t ?
Nick Sabalausky
a at a.a
Thu Oct 13 17:29:27 PDT 2011
"Don" <nospam at nospam.com> wrote in message
news:j77p3i$1eac$1 at digitalmars.com...
>
> The problem is things like:
> int i;
> string s = "0x" ~ ('0' + x);
> since char + int --> int.
>
1. Maybe it would be better to have "char + int --> char"? Sounds much more
sensible to me, although I haven't thought too much about it. When do you
ever add a number to a code unit and *not* expect to end up with another
code unit?
2. I see nothing wrong with needing an explicit cast when going from int to
char, even in that example. What we have now is a teeny, tiny, minor, minor,
minor convenience for some not-particularly-common situations. And the cost
for that negligable benefit is shit like this: "I have "~count~" apples" //
Ka-boom -- I want a compile error on shit like that (heck, even an
implicit to!string would at least be an improvement over what it does now).
More information about the Digitalmars-d
mailing list