Implicit encoding conversion on string ~= int ?

Marco Leise Marco.Leise at gmx.de
Sun Jun 23 23:21:17 PDT 2013


Am Mon, 24 Jun 2013 08:03:27 +0200
schrieb "monarch_dodra" <monarchdodra at gmail.com>:

> Well, chars are integral values... but are integral values char?
> 
> I mean, I only see the promotion making sense one way: Converting 
> a char to an uint can make sense for range analysis, but what 
> about the other way around?
> 
> Same with bool: I can see bool to int making sense, but int to 
> bool not so much, which is why a cast is required (except in an 
> if).
> 
> In C, int to char was important, since char is the "byte" type. 
> But D has byte, so I don't see why we'd allow int to byte...

+1. This is probably the best thinking. It would allow:

value = !value

and its ilk, but prevent

foo(1)

from going to a bool overload. But should that work?:

char D = 'A' + 3;
char E = 4 + 'A';

-- 
Marco



More information about the Digitalmars-d mailing list