[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua language extension for complex number and vector values
- From: "Juris Kalnins" <juris@...>
- Date: Mon, 04 Apr 2011 15:26:13 +0300
On Mon, 04 Apr 2011 14:34:20 +0300, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
Yes, I mean that inside the block, everything is temporary and stored
in static vars in C. The complex C library would have 256 static
pointers to hold temporary userdata, say allocated at the start in
luaopen_complex. complex.enter would start using them instead of
allocating new ones. The expressions in complex.eval would be evaluated
as usual by Lua, but using the temporary userdata.
I feel I have missed something important in your description.
How would you prevent these temporary values from escaping into other parts
of Lua state? If eval gives control to Lua, then it may yield or call
debug hook,
keeping active reference to the temporary values for undefined amount of
time.
What happens with the internal counter on error, and what happens when
argument
to "eval" calls another function?
Can arrays appear anywhere in the expression? I.e. would something like
complex.eval(some_matrix_fn { a * a, a * b, -a * b, -b * b })
work?
However, complex.eval
would duplicate the userdata corresponding to its arguments, using real
allocation, so that they can be returned. I should have written
val1, val2 = complex.eval(a * exp(i*z) + b, a*b+z)
complex.exit would clear the internal counter. Perhaps it is not needed
and this can be done in complex.eval, but it seems clear to explicitly
bracket blocks.