Implicit encoding conversion on string ~= int ?
monarch_dodra
monarchdodra at gmail.com
Sun Jun 23 23:03:27 PDT 2013
On Monday, 24 June 2013 at 00:50:17 UTC, Jonathan M Davis wrote:
> On Sunday, June 23, 2013 19:25:41 Adam D. Ruppe wrote:
>> On Sunday, 23 June 2013 at 16:37:18 UTC, bearophile wrote:
>> > I didn't know that, is this already in Bugzilla?
>>
>> I don't know, but if it is, it is probably marked as won't fix
>> because I'm pretty sure this has come up before, but it is
>> actually by design because a char in C is considered an
>> integral
>> type too.
>
> This is definitely by design. Walter is definitely in the camp
> that thinks that
> chars are integral types, so they follow all of the various
> integral
> conversion rules.
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...
More information about the Digitalmars-d
mailing list