Signed-unsigned comparisons in Phobos

Timon Gehr timon.gehr at gmx.ch
Fri Aug 12 12:43:02 PDT 2011


On 08/12/2011 08:32 PM, Jacob Carlborg wrote:
> On 2011-08-12 20:16, Walter Bright wrote:
>> On 8/12/2011 8:52 AM, Jonathan M Davis wrote:
>>> it's a practice that many
>>> people don't seem to follow (in both C/C++ and D), since it's so
>>> natural to
>>> use int (or auto in D),
>>
>> Back in the olden days of C, it was "best practice" to use int as an
>> index. Times have changed, but old habits die hard.
>
> Just out of curiosity, why was that?
>

Probably because of this:
for(unsigned int i=0;i<n;i++){}    // ok
for(unsigned int i=n-1;i>=0;i--){} // bam!


More information about the Digitalmars-d mailing list