www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Minor proposal: Integer types

reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
I was writing some code today that mixed some different sizes of integers, 
when I realized that the names for the integer types were kind of.. well, 
weird.

D gets its names for integral types from C.  This isn't a very good idea for 
2 reasons:

1, C's integer names tend to be qualitative rather than quantitative; that 
is, names like "short," "long," and "int" may or may not make sense when 
developing for processors with different bit sizes.  On a 64 bit processor, 
for example, "long" doesn't really make sense, as it's the native integer 
size; it's not long, it's regular.  The only one that makes sense is "byte."

2, D's integer names are subtly different from C's.  In C, "int" is the 
native integer size, while in D, it is always 32 bits.  In C, long is 32 
bits, but it's 64 bits in D.

So I was thinking it would be better if D used quantitative names; that is, 
the names tell you the size of the integer.  So it would use int8, int16, 
int32, int64 etc.  This also has the benefit of being expandable - need a 
128-bit integer?  Don't use some nonsensical keyword like "cent," use 
int128.

I know, it's a bit late in the game for something as fundamental as a name 
change for some of the most basic variable types, but it'd be cool. 
Apr 15 2005
parent reply Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
Jarrett Billingsley schrieb am Fri, 15 Apr 2005 17:32:08 -0400:
 I was writing some code today that mixed some different sizes of integers, 
 when I realized that the names for the integer types were kind of.. well, 
 weird.

 D gets its names for integral types from C.  This isn't a very good idea for 
 2 reasons:

 1, C's integer names tend to be qualitative rather than quantitative; that 
 is, names like "short," "long," and "int" may or may not make sense when 
 developing for processors with different bit sizes.  On a 64 bit processor, 
 for example, "long" doesn't really make sense, as it's the native integer 
 size; it's not long, it's regular.  The only one that makes sense is "byte."

 2, D's integer names are subtly different from C's.  In C, "int" is the 
 native integer size, while in D, it is always 32 bits.  In C, long is 32 
 bits, but it's 64 bits in D.

 So I was thinking it would be better if D used quantitative names; that is, 
 the names tell you the size of the integer.  So it would use int8, int16, 
 int32, int64 etc.  This also has the benefit of being expandable - need a 
 128-bit integer?  Don't use some nonsensical keyword like "cent," use 
 int128.
-> dmd/src/phobos/std/stdint.d
Apr 15 2005
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Thomas Kuehne" <thomas-dloop kuehne.thisisspam.cn> wrote in message 
news:bvo5j2-407.ln1 lnews.kuehne.cn...
 -> dmd/src/phobos/std/stdint.d
Well, nevermind then!
Apr 16 2005