lua-users home
lua-l archive

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


> "f = function() end" looks like an anonymous function to me.
> It would have a name in debugger if it were defined like this:
> "function f() end".

In Lua, "function f() end" is just sugar for "f = function() end".
They both produce exactly the same code:

$ echo "f = function () end" | luac -l -
	[...]
	1	[1]	VARARGPREP	0
	2	[1]	CLOSURE  	0 0	; 0x55ca606b2d40
	3	[1]	SETTABUP 	0 0 0	; _ENV "f"
	4	[1]	RETURN   	0 1 1	; 0 out


$ echo "function f() end" | luac -l -
	[...]
	1	[1]	VARARGPREP	0
	2	[1]	CLOSURE  	0 0	; 0x55a30b211d40
	3	[1]	SETTABUP 	0 0 0	; _ENV "f"
	4	[1]	RETURN   	0 1 1	; 0 out

-- Roberto