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

Kagamin via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 20 02:50:40 PST 2014


On Thursday, 20 November 2014 at 08:14:41 UTC, Walter Bright 
wrote:
> Computer math is not math math. It is its own beast, and if 
> you're going to write in a systems programming language it is 
> very important to learn how it works, or you'll be nothing but 
> frustrated.

Understanding how it works doesn't mean error prone practices 
must be forced everywhere. It's not like D can't work with signed 
types.

>> Rust made the same mistake and now a couple of times I've seen 
>> bugs like these
>> being reported. Never seen them in Java or .Net though. I 
>> wonder why...
>
> D is meant to be easily used by C and C++ programmers. It 
> follows the same model of signed/unsigned arithmetic and 
> integral promotions. This is very, very deliberate. To change 
> this would be a disaster.

If unsigned types exist, it doesn't mean they must be forced 
everywhere.

> For example, in America we drive on the right. In Australia, 
> they drive on the left. When I visit Australia, I know this, 
> but when stepping out into the road I instinctively check my 
> left for cars, step into the road, and my foot gets run over by 
> a car coming from the right. I've had to be very careful as a 
> pedestrian there, as my intuition would get me killed.
>
> Don't mess with systems programmers' intuitions. It'll cause 
> more problems than it solves.

Bad things can happen, but why make them more probable instead of 
trying to make them less probable?


More information about the Digitalmars-d mailing list