mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Add curenv to core.
This commit is contained in:
		| @@ -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. | ||||
|   | ||||
| @@ -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. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose