Local Value Arrays
 
 
 

If the number of new locals to be protected is unknown at compile you can use the following macros that create protected arrays of values. One form creates the array on the stack using _alloc() and so is useful inside one function call, the other puts the array in the heap and so can be used across functions. In both cases, you also need to declare a Value** variable to hold the pointer to the array.

Stack-resident Array

Heap-resident Array

Example

Value** items;
value_local_array(items, n);
for (int i = 0; i < n; i++)
  items[i] = Float::intern(data[i]);
pop_value_local_array(items);