flax-lang/flax

Scoping Rules

zhiayang opened this issue · 1 comments

The whole importing/modules/namespaces thing needs a bit of work to be useful. Top on the list: using namespace.

Right now all types and functions in namespaces/static functions in classes have to be fully qualified, which is clearly a pain. Some kind of using construct is important for usability.

Next, public vs private imports. Right now importing something exposes it to everybody who imports you. I'm using that behaviour in the libraries right now, but that shouldn't be the case (by default anyway).

Propose something like public import ... and private import ..., where the latter is the default behaviour, and does not "re-export" whatever was imported.

Also, allow importing modules under their own namespace, eg.
import lib.somefoo as foo to use foo.topLevelFunction() instead of polluting the global namespace.

Also, then: should that automatically put all the top level things from somefoo into a namespace somefoo, or leave it at top-level?

Finally: allow importing files directly by using a string instead of a bunch of dot-operator things.

ok like two years later this is finally implemented