'int' is enough for 'length' to migrate code from x86 to x64

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 20 09:05:41 PST 2014


On 11/20/14 7:29 AM, Sean Kelly wrote:
> On Thursday, 20 November 2014 at 00:08:08 UTC, Andrei Alexandrescu wrote:
>>
>> I think we're in good shape with unsigned.
>
> I'd actually prefer signed.  Index-based algorithms can be tricky to
> write correctly with unsigned index values.

The most difficult pattern that comes to mind is the "long arrow" 
operator seen in backward iteration:

void fun(int[] a)
{
     for (auto i = a.length; i --> 0; )
     {
         // use i
     }
}


Andrei


More information about the Digitalmars-d mailing list