Question about arrays
Etienne
etcimon at gmail.com
Wed Jan 22 13:46:07 PST 2014
On 2014-01-22 3:33 PM, Adam D. Ruppe wrote:
> A memory block (static array, int[N]) is a value type in D; it is just a
> big block of bytes, not a pointer. So what happens here is:
>
> memcpy(&block, slice.ptr, slice.length);
>
>
> Contrast that to:
>
> int[] a = slice;
>
> which compiles (conceptually) into:
>
> a.ptr = slice.ptr;
> a.length = a.length;
>
It's funny that you wrote this `a.length = a.length`, because I was
currently looking at
https://d.puremagic.com/issues/show_bug.cgi?id=11970 right before I read
your message.
But yes, static array / memory blocks vs pointer+len explains it better,
I'm trying to grow an idea of the concept of stacks but it's harder to
work with, I thought it would help me catch an idea of why I couldn't
prevent `ubyte[1024*1024] ub;` from crashing. While working with
buffers, this is going to come in handy!
More information about the Digitalmars-d
mailing list