Walter Bright wrote:
Don wrote:
I would strongly support that. But it doesn't really work.
The problem is size_t. The fact that it's unsigned is a root of all
kinds of evil. It means .length is unsigned!!!
Personally I think that any creation or access to an object which is
larger in size than half the memory space, should be impossible
without a special function call. Providing syntax sugar for this
incredibly rare scenario introduces a plethora of bugs.
size_t is unsigned to line up with C's. ptrdiff_t is the signed version.
You can do things like:
ptrdiff_t d = a.length;
Making size_t signed would have consequences that are largely unknown.
I know. But it's the root of the problem.