lua-users home
lua-l archive

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


> you want the control the unnecessary production of new objects as result of manipulations.

I've written several arithmetic libraries (or rather bindings) [1] and
I've faced this issue, especially when using arithmetic metamethods
that create temporary objects for intermediate results of complicated
expressions. In that case, I've toyed with the idea of allocating
temporary objects in a pool, but never implemented it because it'd
require some info from the caller, such as begin-eval and end-eval [2]
-- not pretty. My conclusion is that all memory management should be
left to Lua. You should trust its garage collection.

[1] https://web.tecgraf.puc-rio.br/~lhf/ftp/lua/
[2] http://lua-users.org/lists/lua-l/2011-04/msg00077.html