|
Fabien wrote:
A good point. That's a form of memoization. Is there a memoize module for Lua like the one in Perl? One can easily do it on demand for a particular function by hand, of course.> If using alpha compilers gives you the heebie jeebies, you can also do > something like this: > > function L(args) > return function(exp) > return assert(loadstring("return function("..args..")" > .." return "..exp.." end"))() > end > end You probably want to perform some compilation caching, indexing compiled functions with their source, so that you keep acceptable performances when lambdas occur in loops (i.e. virtually always).
-- With kind regards Veli-Pekka Tätilä Accessibility, Apps and Coding plus Synths and Music: http://vtatila.kapsi.fi