Signed word lengths and indexes

Walter Bright newshound1 at digitalmars.com
Tue Jun 15 22:01:09 PDT 2010


bearophile wrote:
> This thread was not about linux or Linus or operating systems, it was about
> my proposal of changing indexes and lengths in D to signed words. So let's go
> back to the true purpose of this thread!
> 
> Walter Bright:
>> 1. D source code is supposed to be portable between 32 and 64 bit systems.
>> This would fail miserably if the sign of things silently change in the
>> process.
> 
> I don't understand this, please explain better. If I use a signed word on
> both 32 and 64 bit systems to represent indexes and lengths what bad things
> can this cause?

Changing the sign of size_t from unsigned to signed when going from 32 to 64 
bits will cause a difference in behavior.


>> 2. For an operating system kernel's memory management logic, it still would
>> make sense to represent the address space as a flat range from 0..n, not
>> one that's split in the middle, half of which is accessed with negative
>> offsets. D is supposed to support OS development.
> 
> I don't understand, I don't understand how this is related to lengths and
> indexes, for examples array ones.

A memory manager sees the address space as 0..N, not -N/2..0..N/2



More information about the Digitalmars-d mailing list