Integer conversions too pedantic in 64-bit

Jonathan M Davis jmdavisProg at gmx.com
Tue Feb 15 18:07:49 PST 2011


On Tuesday, February 15, 2011 15:13:33 spir wrote:
> On 02/15/2011 11:24 PM, Jonathan M Davis wrote:
> > Is there some low level reason why size_t should be signed or something
> > I'm completely missing?
> 
> My personal issue with unsigned ints in general as implemented in C-like
> languages is that the range of non-negative signed integers is half of the
> range of corresponding unsigned integers (for same size).
> * practically: known issues, and bugs if not checked by the language
> * conceptually: contradicts the "obvious" idea that unsigned (aka naturals)
> is a subset of signed (aka integers)

It's inevitable in any systems language. What are you going to do, throw away a 
bit for unsigned integers? That's not acceptable for a systems language. On some 
level, you must live with the fact that you're running code on a specific machine 
with a specific set of constraints. Trying to do otherwise will pretty much 
always harm efficiency. True, there are common bugs that might be better 
prevented, but part of it ultimately comes down to the programmer having some 
clue as to what they're doing. On some level, we want to prevent common bugs, 
but the programmer can't have their hand held all the time either.

- Jonathan M Davis


More information about the Digitalmars-d mailing list