Is this reasonable?
Ary Borenszweig
ary at esperanto.org.ar
Thu Dec 5 11:51:54 PST 2013
On 12/5/13 4:35 PM, H. S. Teoh wrote:
> On Thu, Dec 05, 2013 at 03:47:27PM -0300, Ary Borenszweig wrote:
> [...]
>> Cough, cough, make array length be an int.
>>
>> Do you really need arrays that big? :-S
>>
>> (I'm talking to Mr. D Compiler here)
>
> A negative length array makes no sense.
Of course not. And it will never be negative. But make it signed and all
the problems everyone is having several times every month will be gone
forever.
>
> Plus, being a systems language, D should be able to represent an entire
> 64-bit address space as an array of ubytes (even if this is rarely
> done!). If one were to write a kernel in D, it would be laughable to use
> signed array lengths.
You can use raw pointers for that if you are going to write a kernel in
D. Or you can make a struct that wraps a pointer and length, make it
uint and that's it.
But to make array.length uint by default and have these surprises all of
the time just because "a negative length doesn't make sense"... I don't
know, I feel it's not the right way to do it.
More information about the Digitalmars-d-learn
mailing list