Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: allow user to specify importable modules #164

Open
DeedleFake opened this issue Nov 28, 2018 · 0 comments
Open

std: allow user to specify importable modules #164

DeedleFake opened this issue Nov 28, 2018 · 0 comments
Assignees

Comments

@DeedleFake
Copy link
Owner

The module registration system was designed to work like the image package's decoder registration. Unfortunately, there's a large difference that I didn't take into account: Importing a package that registers a new module changes the behavior of every WDTE script parsed. This means that any kind of import of any package that calls std.Register() can break things. For example, if std/arrays imported std/stream in order to use NextFunc or something, suddenly stream becomes importable from WDTE.

To get around this, the currently globally-exposed std.Import should be replaced with a function, func Import(modules ...string) wdte.Importer, which returns a wdte.Importer that only allows the user to import the modules specified.

On top of this, it probably makes sense to remove std/all. Instead, std can pre-register all of the std/** modules, while those modules then don't have to import std at all. The downside to this is that all of those packages will be included in every Go package, but that's probably fine. The standard library's not particularly huge.

@DeedleFake DeedleFake self-assigned this Nov 28, 2018
@DeedleFake DeedleFake changed the title std: allow user to specifiy importable modules std: allow user to specify importable modules Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant