just a few small questions

Derek Parnell derek at psych.ward
Fri Apr 14 17:19:54 PDT 2006


On Sat, 15 Apr 2006 10:01:41 +1000, MM <MM_member at pathlink.com> wrote:

> I'm really interested in using D for my next Game, but I had a few  
> questions...

...

> implementation:
> I'm really not into garbage collection(coming from C) and never had a  
> real
> understanding of tthe difference between stack and heap memory.
> What is the best way to allocate a array like this:
> info a[500][500];
>
> info{
> uint x,y,z;
> }
>

  module whatever;
  private {
    struct info
    {
      uint x,y,z;
    }

    info[500][500] a;
  }

This should allocate the array of structs on the heap in a non-GC manner.

One major difference from C arrays is that the indexes are *used* in the  
reverse order from C. Meaning that in C one would write ...

    item = a[X][Y];

but in D one writes ...

    item = a[Y][X];

-- 
Derek Parnell
Melbourne, Australia



More information about the Digitalmars-d-learn mailing list