Static Associative Arrays

Caligo iteronvexor at gmail.com
Sat Apr 7 23:24:02 PDT 2012


On Sat, Apr 7, 2012 at 11:01 PM, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
>
> What do you mean my static associative arrays? Are you asking why you can't
> initialize a static variable which is an AA at compile time? e.g.
>
> - Jonathan M Davis

The same way I can create a static array:

int[4] = [1, 3, 4, 8];  // has value semantics

and dynamic arrays:

int[] = [1, 4, 2, 4];  // has reference semantics

I want an associative array that has value semantics and it's size
doesn't change, just like static arrays.

P.S.
another point.  I was always under the impression that static arrays
are allocated on the stack whereas dynamic arrays are allocated on the
heap and the GC cleans them up.  After today, I'm not so sure if this
is true.  Are static arrays allocated on the stack?  if so, that would
be another reason to want to have static associative arrays.


More information about the Digitalmars-d-learn mailing list