On Mon, Feb 05, 2018 at 03:23:20PM -0500, Steven Schveighoffer via 
Digitalmars-d wrote:
> On 2/5/18 2:30 PM, H. S. Teoh wrote:
> > Even better yet:
> > 
> >     byte b;
> >     b = -b;         // Deprecation error
> > 
> > WAT????
> 
> In the future, -b will be typed as an int, so you can't reassign it to
> b.  You can see this today with -transition=intpomote:
> 
> Error: cannot implicitly convert expression -cast(int)b of type int to
> byte
[...]

Honestly, this just makes narrow int types basically useless when it
comes to any arithmetic at all.

Sticking to C promotion rules is one of the scourges that continue to
plague D; another example is char -> byte confusion no thanks to C
traditions:

        int f(dchar ch) { return 1; }
        int f(byte i) { return 2; }
        void main() {
                pragma(msg, f('a'));
                pragma(msg, f(1));
        }

Exercise for reader: guess compiler output.


T

-- 
Trying to define yourself is like trying to bite your own teeth. -- Alan Watts

Reply via email to