Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Re-export other modules functions #498

Open
yloiseau opened this issue Aug 31, 2017 · 0 comments
Open

Re-export other modules functions #498

yloiseau opened this issue Aug 31, 2017 · 0 comments

Comments

@yloiseau
Copy link
Contributor

yloiseau commented Aug 31, 2017

It would be nice for a module to be able to expose (export) some or all public functions defined in an other module.

For instance, given

module some.Module

function foo = |a, b| ...
function bar = |x| ...

a module can export some functions as (syntax to be defined)

module my.package.Utils

export some.Module::foo

...

so that a third one can do:

module an.other.One

import my.package.Utils

function main = |args| {
  foo(1, 2) # actually calls some.Module::foo
  bar("plop") # ! no such method...
}

It would ease the creation of facade module for instance.

I see two ways to do this:

  • compile time (e.g. with a macro... which should be available soon) by injecting in the exporting module functions that delegate on the original ones. Advantage: no change to the language if macros are used, no change in the resolution process, easier to implement. A drawback is that the exported module must be available at compile time to do reflection (depending on the features we want, for instance exporting all functions or keeping named parameters), and thus the compilation order becomes relevant;

  • run time by adding some export metadata to a module (in the same spirit as imports) and use this information when resolving a function call: also search functions in modules exported by the modules imported in the module containing the call... more change to the language/runtime, more difficult to implement, but more dynamic and compilation order remains irrelevant.

Ideas?

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

No branches or pull requests

1 participant