I’m pretty much stuck trying to manipulate an existing two-dimensional uLisp array from C (within an extension function). What’s the best way to do this? I tried hard to figure it out reading “Implementation” and the uLisp source code back and forth, but to no effect.
Should I use sp_setf
to do it? If so, what do I have to pass to this function? When I pass
cons(fn_aref(cons(array, cons(number(x), cons (number(y), NULL))), env), cons(number(newvalue), NULL))
I get “Error: unknown variable: 1” (assuming the array has been initialized with ‘1’ before). So obviously the pointer returned by fn_aref
is interpreted wrong because it already points to the value stored in array[x][y].
Thus I assume I should not use sp_setf
to change the value but rather utilize the result of getarray(...)
directly. But I cannot figure out whether I can safely access the memory cell the “pointer to a pointer” obtained by getarray(...)
refers to, or rather I’m not sure what exactly this pointer points to.
So, in short, what do I need to do within a C function to store a new value (in this case, just a number) in a cell of a two-dimensional uLisp array? Any help greatly appreciated!