lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2011/4/3 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
> 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.

Hi Luiz,

thank you for your feedback, I feel better now that I know that my
problem is completely understood. In general you know that with
LuaJIT2+FFI now Lua is becaming competitive with fortran/c for
numerical calculation but complex numbers are a real big design
problem with Lua with no easy solution. Also matrix are a problem
because the mechanism of userdata/metatable is problematic because it
can spoils the LuaJIT2 optimizations.

> 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?

I didn't understood your point and I don't know any easy solution for
the moment :-/

I have the idea that Lua VM should be modified to allow to define
local variables that span multiple stack slots but I don't know if the
idea is sound or not.

I'm thinking to define another language more oriented to mathematics
and to use Lua as a target language but for me moment is just a vague
idea.

-- 
Francesco