moonscript
moonscript copied to clipboard
How can I make a named function?
Hello,
How can I create a non-anonymous function? This is the Lua I want:
local function foo()
end
This is what I tried to do:
foo = foo() ->
Clearly that doesn't work. Could not find an answer anywhere.
I ask because I would like to use the Lua outliner. I would like to avoid seeing "Anonymous" everywhere. :garlic:
Thanks
As far as I'm concerned, there is no way to do this with MoonScript. Both local foo = function()end
and local function foo() end
are roughly equivalent in Lua already, so the first is the way that MoonScript went with.
Maybe it would be interesting to see how this could be made, but are there other benefits beside debugging?
The only possible benefit is that PUC-Rio Lua has an OP_SELF
bytecode that optimizes the case of defining function x:y()
that MoonScript can't take advantage of.