On 4/2/13 3:49 AM, Don wrote:
IMHO, array.length is *the* place where unsigned does *not* work. size_t
should be an integer. We're not supporting 16 bit systems, and the few
cases where a size_t value can potentially exceed int.max could be
disallowed.

The problem with unsigned is that it gets used as "positive integer",
which it is not. I think it was a big mistake that D turned C's
"unsigned long" into "ulong", thereby making it look more attractive.
Nobody should be using unsigned types unless they have a really good
reason. Unfortunately, size_t forces you to use them.

I used to lean a lot more toward this opinion until I got to work on a C++ codebase using signed integers as array sizes and indices. It's an pain all over the code - two tests instead of one or casts all over, more cases to worry about... changing the code to use unsigned throughout ended up being an improvement.

Andrei

Reply via email to