Annoyance with new integer promotion deprecations

Walter Bright newshound2 at digitalmars.com
Tue Feb 6 02:30:03 UTC 2018


On 2/5/2018 3:18 PM, Timon Gehr wrote:
> Neither byte nor dchar are C types.

"byte" is a C "signed char". On Posix systems, a dchar maps to wchar_t, although 
wchar_t is a typedef not a distinct type. It's a bit complicated :-)


> The overloading rules are fine, but byte should not implicitly convert to 
> char/dchar, and char should not implicitly convert to byte.

Maybe not, but casting back and forth between them is ugly. Pascal works this 
way, and it was one of the things I wound up hating about Pascal, all those ORD 
and CHR casts.

A reasonable case could be made for getting rid of all implicit conversions. But 
those are there for a reason - it makes writing code more natural and easy. It 
allows generic code to work without special casing. And the cost of it is 
sometimes you might make a mistake.


More information about the Digitalmars-d mailing list