Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow type names with "." character #118

Open
daurnimator opened this issue Aug 26, 2018 · 3 comments
Open

Allow type names with "." character #118

daurnimator opened this issue Aug 26, 2018 · 3 comments

Comments

@daurnimator
Copy link

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"

@mascarenhas
Copy link
Collaborator

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.

@daurnimator
Copy link
Author

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)

@mascarenhas
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants