Skip to content

Allow type names with "." character #118

Description

@daurnimator

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"

Activity

  1. mascarenhas commented on Aug 27, 2018

    @mascarenhas
    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.

  2. daurnimator commented on Aug 28, 2018

    @daurnimator
    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)
    
  3. mascarenhas commented on Aug 28, 2018

    @mascarenhas
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions