just a few small questions
Jarrett Billingsley
kb3ctd2 at yahoo.com
Tue Apr 18 17:11:56 PDT 2006
"MM" <MM_member at pathlink.com> wrote in message
news:e23tmv$1gaq$1 at digitaldaemon.com...
> Why is wrong with using a Global? When I need an array for the whole time
> and
> more than half of the subs need to access it, I just don't want to use
> those
> annoying pointers the whole time :).. how is this done in D?
Well, if you're programming in a C-style fashion, where you just have a
bunch of global data and a bunch of functions to manipulate it.. I suppose
it's kind of _messy_ and certainly not my preferred method, but there's
nothing stopping _you_ from doing it :)
One of the problems of using a large global array is that it's allocated in
the static data segment. This isn't a problem if you just define
int[500][500] x;
But if you initialize any of it statically:
int[500][500] x = [0 : [0 : 1]];
(which means set x[0][0] = 1)
It makes the EXE size jump up quite a bit. In this case, by about 1MB.
You can get around this by using static module constructors though:
int[500][500] x;
static this()
{
x[0][0] = 1;
}
More information about the Digitalmars-d-learn
mailing list