typedlua icon indicating copy to clipboard operation
typedlua copied to clipboard

Allow type names with "." character

Open daurnimator opened this issue 6 years ago • 3 comments

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"

daurnimator avatar Aug 26 '18 11:08 daurnimator

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.

mascarenhas avatar Aug 27 '18 15:08 mascarenhas

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)

daurnimator avatar Aug 28 '18 01:08 daurnimator

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.

mascarenhas avatar Aug 28 '18 01:08 mascarenhas