proposal: capacity variable for dynamic arrays

Ameer Armaly ameer_armaly at hotmail.com
Mon Jul 10 13:32:47 PDT 2006


"Lionello Lunesu" <lionello at lunesu.remove.com> wrote in message 
news:e8u973$21uo$1 at digitaldaemon.com...
> What's the capacity of a slice?
>
The capacity of a slice is strictly the number of elements in that slice; 
any expansion in capacity would result in a new memmory block.
> Futhermore, the capacity can't be stored in the memory block, since you 
> don't know the start and end of the block. Could be stored in the array 
> variables itself (as are length and ptr), but that would make the 
> sizeof(array) and strange 12, probably being padded to 16, resulting in 
> twice the mem transfer for array arguments, return values.
>
> L.
My favorite solution is the one mentioned previously in which capacity is a 
virtual property that obtains the block size from the gc itself in some 
manner.
>
> 





More information about the Digitalmars-d mailing list