Skip to content

std: allow user to specify importable modules #164

Description

@DeedleFake

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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions