<font face="arial, helvetica, sans-serif">So D is really finicky with integer casts. Basically everything that might produce a loss of data warning in C is an outright compile error.</font><div><font face="arial, helvetica, sans-serif">This results in a lot of explicit casting.</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Now I don't take issue with this, actually I think it's awesome, but I think there's one very important usability feature missing from the compiler with such strict casting rules...</font></div>
<div><font face="arial, helvetica, sans-serif">Does the compiler currently track the range of a value, if it is known? And if it is known, can the compiler stop complaining about down casts and perform the cast silently when it knows the range of values is safe.</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">int x = 123456;</font></div><div><font face="arial, helvetica, sans-serif">x &= 0xFF; // x is now in range 0..255; now fits in a ubyte</font></div>
<div><font face="arial, helvetica, sans-serif">ubyte y = x; // assign silently, cast can safely be implicit</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">I have about 200 lines of code that would be so much more readable if this were supported.</font></div>
<div><font face="arial, helvetica, sans-serif">I'm finding that in this code I'm writing, casts are taking up more space on many lines than the actual term being assigned. They are really getting in the way and obscuring the readability.</font></div>
<div><font face="arial, helvetica, sans-serif">Not only masks, comparisons are also often used of limit the range of values. Add D's contracts, there is good chance the compiler will have fairly rich information about the range of integers, and it should consider that while performing casts.</font></div>