lua-users home
lua-l archive

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

>Well, it is, but it's ugly: you'd need letrec and simultaneous assignment:
>f, g = function () ... g() ... end, function () ... f() ... end
>would work if the assignments to f and g were scoped over the right hand
>side. Of course, in normal assignments they're not

Like Roberto pointed out, the value of variables inside functions is determined
at runtime, not compiled time, and this now works even for local variables
(now that we don't have frozen values, aka % upvalues.)

So, in your example, you could write

local f,g
f, g = function () ... g() ... end, function () ... f() ... end