Signed-unsigned comparisons in Phobos

Jacob Carlborg doob at me.com
Sat Aug 13 05:27:48 PDT 2011


On 2011-08-13 00:08, Walter Bright wrote:
> On 8/12/2011 11:32 AM, 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?
>>
>
> 1. size_t didn't exist
>
> 2. sizeof(int) == sizeof(pointer) pretty much everywhere
>
> 3. Signed indices meant you could index backwards
>
> 4. K+R used 'int' as an index everywhere

Ok, I see, thanks for the reply.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list