bearophile can say "i told you so" (re uint->int implicit conv)

bearophile bearophileHUGS at lycos.com
Thu Mar 28 14:58:04 PDT 2013


Adam D. Ruppe:

> if (arg == typeid(uint)) {
> 	int e = va_arg!uint(_argptr);
> 	a = to!string(e);
> }
>
>
> See, I copy/pasted it from the int check, but didn't update the 
> type on the left hand side. So it correctly pulled a uint out 
> of the varargs, but then assigned it to an int, which the 
> compiler accepted silently,

If you remove the implicit uint==>int assignment from D you have 
to add many cast() in the code. And casts are dangerous, maybe 
even more than implicit casts. That's why D is the way it is.

Maybe here a cast(signed) is a bit safer.

I didn't write a Bugzilla request to remove the implicit 
uint==>int assignment. (I think the signed-unsigned comparisons 
are more dangerous than those signed-unsigned assignments. But 
maybe too is a problem with no solution).

------------------

Alex Rønne Petersen:

>I'm personally in favor of fixing some of the serious issues we 
>have in
the language once and for all<

That's quite hard to do because the problems are not easy to 
fix/improve, it takes time and a _lot_ of thinking. You can't 
quickly fix "shared", memory ownership problems, redesign things 
to not preclude the future creation of a far more parallel GC, 
and so on. And even much simpler things like properties need time 
to be redesigned. Maybe in the D world there's some need for a 
theoretician, beside Andrei.

But I agree most of the time should now be used facing the larger 
holes, design problems and missing parts of D, and less on 
everything else. Because the more time passes, the less easy it 
becomes to fix/improve those things. It's a shame to have to 
leave D after all this work just because similar problems get 
essentially frozen.

Bye,
bearophile


More information about the Digitalmars-d mailing list