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

Keith Packard keithp at keithp.com
Sat Jan 15 11:06:26 PST 2005


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.  As boxes 
are rarely left uninitialized any more, this doesn't get hit all that 
often, except in the case of a resizable array.  You can see this with:

	> int[...] a;
	> &int ip = &a[0];
	> ip
	Unhandled exception uninitialized_value ("Uninitialized value")
	<stdin>:3:     ip;

Contrast this with:

	> typedef struct { int i; } s_t;
	> s_t[...] a;
	> &s_t sp = &a[0];
	> sp
	{i = <uninit>}

Arrays are currently not automatically included in this particular 
automatic initialization.

I tried (briefly) to make it work, but finding the array dimension 
information is hard -- the dimensions are stored in an array which is 
created and initialized when the array declaration is executed.  For 
declarations in global scope, or for resizable arrays, the answer is easy.

However, if this declaration is in a dynamic scope, the array itself is
hanging from a frame somewhere.  I don't currently have enough information
to go find this frame, and I'm not quite sure how I'm going to go about
locating it yet.

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

-keith


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
Url : /pipermail/nickle/attachments/20050115/2ea6dfad/attachment.pgp


More information about the Nickle mailing list