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

Walter Bright newshound2 at digitalmars.com
Thu Apr 4 12:10:28 PDT 2013


On 4/2/2013 8:10 PM, Steven Schveighoffer wrote:
> On Tue, 02 Apr 2013 16:32:21 -0400, Walter Bright <newshound2 at digitalmars.com>
> wrote:
>> For example, with a signed array index, a bounds check is two comparisons
>> rather than one.
>
> Why?
>
> struct myArr
> {
>     int length;
>     int opIndex(int idx) { if(cast(uint)idx >= cast(uint)length) throw new
> RangeError(); ...}
> }

Being able to cast to unsigned implies that the unsigned types exist. So no 
improvement.



More information about the Digitalmars-d mailing list