[Nickle] Nickle bug/misfeature: storage for growable arrays of growable arrays

Bart Massey nickle at po8.org
Sat Jan 15 11:48:43 PST 2005

In message <E1CptFi-0007HZ-8p at evo.keithp.com> you wrote:
> Around 0 o'clock on Jan 15, "Bart Massey" wrote:
> > Nickle has a nice feature wrt arrays: storage is
> > auto-allocated.  For growable arrays, this means that
> > this works
> Urgh.  Nickle has two separate mechanisms for initializing storage, one is 
> when variables are declared -- the compiler emits code to create an 
> appropriate value if none is provided.  The second mechanism is when an 
> uninitialized box is fetched -- the box is filled with a default value for 
> the specified type, but only if it is of type struct or
> union.

Sigh.  Do we want this
   struct {int x;} s;
to be different from this?
   struct {int x;} s = {};
I think there's a case to be made for this distinction.  If
so, it's clear what to do with structures, unions, and
normal arrays, and shouldn't require the current lazy
initialization mechanism.

For growable arrays, it gets more complicated, since
growable arrays of objects (of any type) don't have a
"default value" like hashes do.  This should probably be
fixed.  Perhaps things like
   int[...][...] a = {{} ...};
should work?

> Also, what should I do with '*' arrays?  Any size I pick seems wrong.

Given the previous it seems clear that a * array that is
uninitialized is not an array.  This makes things much easier.

Am I confused somewhere?


More information about the Nickle mailing list