Can we disallow appending integer to string?

Stanislav Blinov via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 19 12:05:29 PDT 2017


On Wednesday, 19 April 2017 at 18:40:23 UTC, H. S. Teoh wrote:

> A few extra keystrokes to type cast(int) or cast(char) ain't 
> gonna kill nobody. In fact, it might even save a few people by 
> preventing certain kinds of bugs.

Yup. Not to mention one could have

@property
auto numeric(Flag!"unsigned" unsigned = No.unsigned, C)(C c) 
if(isSomeChar!C)
{
     return cast(IntOfSize!(C.sizeof, unsigned))c;
}

auto v = 'a'.numeric;

...or even have an equivalent as a built-in property of character 
types...


More information about the Digitalmars-d-learn mailing list