'int' is enough for 'length' to migrate code from x86 to x64
Ary Borenszweig via Digitalmars-d
digitalmars-d at puremagic.com
Thu Nov 20 06:22:00 PST 2014
On 11/20/14, 5:02 AM, Walter Bright wrote:
> On 11/19/2014 5:03 PM, H. S. Teoh via Digitalmars-d wrote:
>> If this kind of unsafe mixing wasn't allowed, or required explict casts
>> (to signify "yes I know what I'm doing and I'm prepared to face the
>> consequences"), I suspect that bearophile would be much happier about
>> this issue. ;-)
>
> Explicit casts are worse than the problem - they can easily cause bugs.
>
> As for me personally, I like having a complete set of signed and
> unsigned integral types at my disposal. It's like having a full set of
> wrenches that are open end on one end and boxed on the other :-) Most of
> the time either end will work, but sometimes only one will.
>
> Now, if D were a non-systems language like Basic, Go or Java, unsigned
> types could be reasonably dispensed with. But D is a systems programming
> language, and it ought to have available types that match what the
> hardware supports.
>
Nobody is saying to remove unsigned types from the language. They have
their uses. It's just that using them for an array's length leads to
subtle bugs. That's all.
More information about the Digitalmars-d
mailing list