[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua language extension for complex number and vector values
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Sun, 3 Apr 2011 15:25:54 -0300
> function f(a, b, z)
> return a * exp(i*z) + b
> end
>
> The problem of the function above is that it looks clear and simple
> but in reality it is a disaster in term of run-time execution because
> a lot of small objects have to be created on the heap every time that
> it is executed.
Indeed. I fell the same pain when I write bindings for math operations
(and I've written several). I wish Lua told me that it wants a temporary
value. I could then use static allocation for those.
The only way out that I can see is to use an explicit block as in say
complex.enter()
complex.eval(a * exp(i*z) + b, a*b+z)
complex.exit()
Not nice, but doable.
Can anyone see a better solution?