lua-users home
lua-l archive

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


> Since in Lua all functions are really anonymous, recursion seems to be fragile. 

This has nothing to do with recursion. It's a consequence of dynamic binding.
Consider this:

	function hello()
		print"Hello world"
	end

	print=nil
	hello()		-- error!

Is there anything to be fixed in this code??

If you want to force static binding, you can do it with

	do
		local print=print
		function hello()
			print"Hello world"
		end
	end