diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b4fb4f8..ff690b43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ All notable changes to this project will be documented in this file. ## Unreleased - ??? +- Add `(curenv)`. - Change `net/read`, `net/chunk`, and `net/write` to raise errors in the case of failures. - Add `janet_continue_signal` to C API. This indirectly enables C functions that yield to the event loop to raise errors or other signals. diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 931dcebb..e6f0fcf0 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -2069,6 +2069,14 @@ (if ec "\e[0m" ""))) (eflush)) +(defn curenv + "Get the current environment table. Same as (fiber/getenv (fiber/current)). If n + is provided, gets the nth prototype of the environment table." + [&opt n] + (var e (fiber/getenv (fiber/current))) + (if n (repeat n (if (= nil e) (break)) (set e (table/getproto e)))) + e) + (defn run-context "Run a context. This evaluates expressions in an environment, and is encapsulates the parsing, compilation, and evaluation.