[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to provide a name for c function to lua_getinfo()?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 8 Nov 2023 10:28:21 -0300
> "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