Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Add support for imports? #15

Open
mindplay-dk opened this issue May 27, 2016 · 1 comment
Open

Add support for imports? #15

mindplay-dk opened this issue May 27, 2016 · 1 comment

Comments

@mindplay-dk
Copy link

Any plans to add an import statement?

For example:

import IO.*

def test {
  return isDirectory("foo")
}

One should be able to import individual functions from a namespace as well.

This would be useful e.g. for DSL-like namespaces - e.g. parser libraries, routers, etc. where you have lots of factory functions packed into a single namespace.

@mindplay-dk
Copy link
Author

Perhaps this is by design? May be you don't want to deal with filename references. I could understand that.

It looks like you get around this very nicely by carefully organizing your namespaces in the Skew compiler project itself, but is this never going to be a requirement? Perhaps not.

If not, then maybe some means of addressing one namespace from within another namespace and/or scope?

So like, without this feature:

namespace Hello {
  def hello {
    World.world
  }
}

namespace World {
  def world {}
}

@export
def test {
  Hello.hello
}

And adding, say, a use statement, instead:

namespace Hello {
  use World    # imports the world function from the World namespace
  def hello {
    world      # calls the imported function
  }
}

namespace World {
  def world {}
}

@export
def test {
  use Hello as H   # imports the Hello namespace with an alias H
  H.hello          # calls the imported function
}

This is probably simpler and avoids dealing with files.

(if something like a package manager is implemented in the future, avoiding file paths entirely, even for external dependencies, would then likely be consistent and preferable)

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

No branches or pull requests

1 participant