Austin Hastings wrote:

Another question: If you ask for a value and get it, does the array
grow? Or does that happen only on assignment? (

Arrays (or hashes) don't grow on reading - never.

And another anser from current low level (list.c & classes/Array.pmc)

* Return value
* ------------
*
* List get functions return a (void*) pointer to the location of the
* stored data. The caller has to extract the value from this
* pointer.
*
* For non existent data beyond the dimensions of the
* array a NULL pointer is returned.
*
* For non existing data inside sparse holes, a pointer (void*)-1
* is returned.
* The caller can decide to assume these data as undef or 0 or
* whatever is appropriate.

As the returned ptr is a PMC ** you/the class interface can do what is appropriate:

if (ret == 0)
internal_exception(OUT_OF_BOUNDS, "Array index out of bounds!\n");
/* XXX getting non existant value, exception or undef?
* current is for perlarray */
if (ret == (void*) -1)
value = undef(interp);
else {
value = *(PMC**) ret;
if (value == NULL) /* XXX same here */
value = undef(interp);
}


leo

Reply via email to