Slices and arrays problems?

Adam D. Ruppe destructionator at gmail.com
Mon Jul 1 11:05:04 PDT 2013


On Monday, 1 July 2013 at 17:34:39 UTC, Damian wrote:
> Isn't the buffer just an array with a fixed length?

No. A static array is just a block of memory (like in C), whereas 
a slice is a struct with a length and pointer to a memory block.

A ref slice would write to the length/pointer, which doesn't 
exist with a static array.

You can get a slice from a static array by putting [] on the end, 
but to be ref, you'll need a variable with the type "int[]" 
because then the length and pointers can be changed by the 
function that accepts it.


More information about the Digitalmars-d-learn mailing list