mirror of
https://github.com/janet-lang/janet
synced 2026-10-04 14:51:40 +00:00
Move print in source code to io module.
print now reads the dynamic binding for :out when choosing where to write to.
This commit is contained in:
@@ -852,6 +852,19 @@
|
||||
(set prev ~(if-let [,sym ,prev] ,next-prev)))
|
||||
prev)
|
||||
|
||||
(defmacro with-dyns
|
||||
"Run a block of code in a new fiber that has some
|
||||
dynamic bindings set. The fiber will not mask errors
|
||||
or signals, but the dynamic bindings will be properly
|
||||
unset, as dynamic bindings are fiber local."
|
||||
[bindings & body]
|
||||
(with-syms [currenv env fib]
|
||||
~(let [,currenv (,fiber/getenv (,fiber/current))
|
||||
,env (,table/setproto (,table ,;bindings) ,currenv)
|
||||
,fib (,fiber/new (fn [] ,;body) :)]
|
||||
(,fiber/setenv ,fib ,env)
|
||||
(,resume ,fib))))
|
||||
|
||||
(defn partial
|
||||
"Partial function application."
|
||||
[f & more]
|
||||
|
||||
Reference in New Issue
Block a user