Closed SkyyySi closed 1 year ago
Added a different syntax to support export metamethods for a module by
export.<name> = "My module"
export.<call> = (...) -> -- ...
that compiles to
local _module_0 = setmetatable({ }, { })
getmetatable(_module_0).__name = "My module"
getmetatable(_module_0).__call = function(...) end
return _module_0
Because the statement exporting item with assignment will always leave a local variable. A new syntax for disabling local variable creation when doing export could be a better way for metamethods (Or we may get messy local variables named __call
, __eq
and etc).
I think it would be useful if we could use things like this:
In some Lua environments, like Awesome WM, it is common practice to use modules as both namespaces and as a constructor.