lua-users home
lua-l archive

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



On Fri, Nov 18, 2011 at 10:43 PM, William C. Bubel <wcbubel@gmail.com> wrote:
On 11/18/2011 11:41 AM, GrayFace wrote:
> What I don't like about 5.2 is that 5.1 is cleaner in many ways.
> ...
> function definitions always produce a new function

Can somebody clarify this for me? What's the situation in 5.2 where the
function keyword wouldn't produce a function object?


function foo()

  local function bar()
  end

  print(bar)
end

foo()
foo()


In Lua 5.1, a call to function "foo" will create a new instance of function "bar" each time. Lua 5.2 will create only one instance if "bar" has the same upvalues each time.