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:
Calvin Rose
2019-04-16 19:10:01 -04:00
parent ddaa5e34e6
commit 513d551df6
6 changed files with 63 additions and 20 deletions
+13
View File
@@ -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]