lua-users home
lua-l archive

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


On Mon, Aug 3, 2009 at 3:17 PM, Leo Razoumov<slonik.az@gmail.com> wrote:
> Is it possible to do something in Lua and somehow control use of
> temporary objects when dealing with typical +-*/ math operations in
> Lua?? The underlying math library API is of the older variety and
> expects user to do all the resource allocations.

two ideas: (not that i have done anything similar)

1: parse a user string with the whole expression to build the operating objects:

m=import "matrix"
m.var("A") = {.... data...}
m.var("B") = {....more data...}
for n=1,1000 do
   m.oper ("A = A * B")
end
print (m.get("A"))


2: override operators in your userdata; but don't make them calculate,
make them generate the calculators, a bit like LPEG constructing
operators

-- 
Javier