lua-users home
lua-l archive

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


Thanks for the replies everyone. Yes, aware that "do .. end" isnt directly related to closures, it was of course designed to make the local variable private to the closure so that the recursion was no longer fragile.

I still think there might be some value in a distinguished variable that held the "current" function so that at least directly recursive functions could be written in a more robust manner.

--Tim


On Apr 10, 2012, at 1:47 PM, Wim Couwenberg wrote:

>> _G.fact = fact
> 
> In Lua 5.2 make that _ENV.fact = fact.  It avoids the silly _G
> convention *and* saves yet another table lookup.  :-)
> 
> Bye,
> Wim
>