mirror of
https://github.com/janet-lang/janet
synced 2025-01-13 00:50:26 +00:00
Add curenv to core.
This commit is contained in:
parent
5377e10532
commit
f7c556ed8d
@ -2,6 +2,7 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## Unreleased - ???
|
## Unreleased - ???
|
||||||
|
- Add `(curenv)`.
|
||||||
- Change `net/read`, `net/chunk`, and `net/write` to raise errors in the case of failures.
|
- 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
|
- Add `janet_continue_signal` to C API. This indirectly enables C functions that yield to the event loop
|
||||||
to raise errors or other signals.
|
to raise errors or other signals.
|
||||||
|
@ -2069,6 +2069,14 @@
|
|||||||
(if ec "\e[0m" "")))
|
(if ec "\e[0m" "")))
|
||||||
(eflush))
|
(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
|
(defn run-context
|
||||||
"Run a context. This evaluates expressions in an environment,
|
"Run a context. This evaluates expressions in an environment,
|
||||||
and is encapsulates the parsing, compilation, and evaluation.
|
and is encapsulates the parsing, compilation, and evaluation.
|
||||||
|
Loading…
Reference in New Issue
Block a user