Add *module/make-env*

This commit is contained in:
Calvin Rose 2024-05-15 20:16:42 -05:00
parent 9946f3bdf4
commit fdaf2e1594
2 changed files with 4 additions and 1 deletions

View File

@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file.
## Unreleased - ???
- Add *module/make-env* dynamic binding
- Add buffer/format-at
- Add long form command line options for readable CLI usage
- Fix bug with `net/accept-loop` that would sometimes miss connections.

View File

@ -2771,6 +2771,7 @@
(defdyn *module/paths* "Dynamic binding for overriding `module/cache`")
(defdyn *module/loading* "Dynamic binding for overriding `module/cache`")
(defdyn *module/loaders* "Dynamic binding for overriding `module/loaders`")
(defdyn *module/make-env* "Dynamic binding for creating new environments for `import`, `require`, and `dofile`. Overrides `make-env`.")
(def module/cache
"A table, mapping loaded module identifiers to their environments."
@ -2958,7 +2959,7 @@
:core/stream path
(file/open path :rb)))
(def path-is-file (= f path))
(default env (make-env (curenv)))
(default env ((dyn *module/make-env* make-env)))
(def spath (string path))
(put env :source (or source (if-not path-is-file spath path)))
(var exit-error nil)