digitalmars.D - Re: Signed word lengths and indexes
- bearophile <bearophileHUGS lycos.com> Jun 15 2010
- Walter Bright <newshound1 digitalmars.com> Jun 15 2010
- bearophile <bearophileHUGS lycos.com> Jun 16 2010
- Walter Bright <newshound1 digitalmars.com> Jun 16 2010
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?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. Bye, bearophile
Jun 15 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
Jun 15 2010
Walter Bright:Changing the sign of size_t from unsigned to signed when going from 32 to 64 bits will cause a difference in behavior.<
I have proposed to use a "signed word" on both 32 and 64 bits systems. So where's the difference in behaviour?A memory manager sees the address space as 0..N, not -N/2..0..N/2<
If D arrays use signed words as indexes on 32 bit systems then only half of the original length can be used. The numbers in 0..N/2 are a subset of half of the unsigned number range. Bye, bearophile
Jun 16 2010
bearophile wrote:Walter Bright:Changing the sign of size_t from unsigned to signed when going from 32 to 64 bits will cause a difference in behavior.<
I have proposed to use a "signed word" on both 32 and 64 bits systems. So where's the difference in behaviour?
If we go back in the thread, the argument for the signed size_t argument was for 64 bit address spaces. With 32 bit address spaces, objects larger than 31 bits are needed.
Jun 16 2010