skew icon indicating copy to clipboard operation
skew copied to clipboard

Add support for imports?

Open mindplay-dk opened this issue 9 years ago • 1 comments

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 avatar May 27 '16 07:05 mindplay-dk

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)

mindplay-dk avatar Jan 11 '17 20:01 mindplay-dk