lua-users home
lua-l archive

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

In order for the following code to cache closures in 5.2.0-work4,

  for i=1,1000 do
      if i % 2 == 0 then return false else return i end

it currently needs to be rewritten as

  for i=1,1000 do
      if i % 2 == 0 then return false else return i end

Couldn't it cache this case without rewriting?  Defining an anonymous
function and then immediately calling it (once) is a common pattern
for doing statements inside expressions.  The lifetime of such a
function does not extend beyond that normal lifetime of its variables,
so it's not really used as a closure.  That is true unless you did
something odd with the debug library to grab the currently running
function and store it away somewhere for later use.