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
sorry this isn't more clear -- the short answer is, you just need to call env.StandardSetup() or env.ImportPackageBuilder() first in order
to use import. I added a test to demonstrate, so it goes like this:
Rationale: a while back, some users requested sandboxing capability. They
wanted not all functions to be available by default, to support running in environments
where we don't want all scripts going to disk, for example.
If you take a look at the implementation of StandardSetup() (called by the zygo repl, for instance) at https://github.com/glycerine/zygomys/blob/master/zygo/repl.go#L387
you can see all the things it does. It calls env.ImportPackageBuilder()
which enables imports, for example. It also defines a bunch
of macros that you may or may not find useful. If they aren't useful,
you can just do the env.ImportPackageBuilder() to only get imports.
The idea was that sandboxes can write reduced versions of StandardSetup() to
restrict the capabilities offered to scripts.
There are also some other pre-defined subsets of functions to
make it easy to isolate scripts, to provide more or less functionality. See
If you start an environment with NewZlispSandbox() instead of NewZlisp(),
for instance you get a very trimmed down set of capabilities.
Anyway, thanks for asking, and I'll leave this open as a form of documentation for others. Any other questions, just raise an another issue. Or feel free to follow up
here if anything else on imports or packages needs clarifying.
Not sure if this is the correct place to ask...
I try to use the import statement, but get an error:
and the file
foo
in the same directory:I also tried
(package "foo" ....)
like in the example fileprepackage
in the tests directory, but also this doesn't work. The error I get isThe text was updated successfully, but these errors were encountered: