You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 callsstd.Register()
can break things. For example, ifstd/arrays
importedstd/stream
in order to useNextFunc
or something, suddenlystream
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 awdte.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 thestd/**
modules, while those modules then don't have to importstd
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.The text was updated successfully, but these errors were encountered: