The Case Against Autodecode

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 2 15:35:55 PDT 2016


On 03.06.2016 00:26, Walter Bright wrote:
> On 6/2/2016 3:11 PM, Timon Gehr wrote:
>> Well, this is a somewhat different case, because 10000 is just not
>> representable
>> as a byte. Every value that fits in a byte fits in an int though.
>>
>> It's different for code units. They are incompatible both ways.
>
> Not exactly. (c == 'รถ') is always false for the same reason that (b ==
> 1000) is always false.
> ...

Yes. And _additionally_, some other concerns apply that are not there 
for byte vs. int. I.e. if b == 10000 is disallowed, then c == d should 
be disallowed too, but b == 10000 can be allowed even if c == d is 
disallowed.

> I'm not sure what the right answer is here.

char to dchar is a lossy conversion, so it shouldn't happen.
byte to int is a lossless conversion, so there is no problem a priori.


More information about the Digitalmars-d mailing list