typedlua
typedlua copied to clipboard
Allow type names with "." character
As type names inhabit a global namespace, I would like to use some sort of namespacing. To follow lua module name convention, I'd like to use .
as a separator. However this results in a syntax error:
interface foo.bar
const qux : (self) -> ()
end
Perhaps you should allow a quoted name? e.g. interface "foo.bar"
The intent was for the module system to do that namespacing, the way Titan is doing it, just never got around to doing that for Typed Lua. It should have been done that way from the start, as it is more difficult to retrofit on the existing compiler. Knowing the difficulty was also the reason I advocated for the adding modules to Titan right away, and was sad to see it removed in the "Pallene" Lablua fork of that.
What do you mean by "module system" here?
I could understand using a namespaced require
/include
. e.g.
somemodule = require "somemodule"
foo: (somemodule.someinterface) -> (integer)
That was exactly the plan, and the way it is done in Titan. Dotted type names are canonicalized to fully qualified (think Java-style) type names if they reference an imported module, and the typechecker then keeps a global registry of module types.
For Typed Lua the easiest way to do the same it is probably a pass over the AST prior to typechecking that canonicalizes dotted type names, instead of doing all in a single pass like Titan's typechecker does.