lua-users home
lua-l archive

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

> In Python you can pass the function object as a default parameter to
> work around this problem. However, I have no idea how to work around
> this in Lua. Upvalues don't work, because the variable is created
> after the function definition has been evaluated. Just for the fun of
> it, ideas anyone?

As you said, it's not straightforward, but you can do it with upvalues:

function f()
  local g = {}
  g.f = function()

-- Cassino