Update changelog and allow evaluating streams with dofile.

This commit is contained in:
Calvin Rose 2021-10-30 14:41:01 -05:00
parent 34c7f15d6d
commit 9cc4e48124
3 changed files with 19 additions and 5 deletions

View File

@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
## ??? - Unreleased
- Allow evaluating ev streams with dofile.
- Fix `ev` related bug with operations on already closed file descriptors.
- Add struct and table agnostic `getproto` function.
- Add a number of functions related to structs.
- Add prototypes to structs. Structs can now inherit from other structs, just like tables.
- Create a struct with a prototype with `struct/with-proto`.
- Deadlocked channels will no longer exit early - instead they will hang, which is more intuitive.
## 1.18.1 - 2021-10-16

View File

@ -2590,7 +2590,7 @@
@{})
(defn dofile
`Evaluate a file and return the resulting environment. :env, :expander,
`Evaluate a file, file path, or stream and return the resulting environment. :env, :expander,
:evaluator, :read, and :parser are passed through to the underlying
run-context call. If exit is true, any top level errors will trigger a
call to (os/exit 1) after printing the error.`
@ -2602,8 +2602,9 @@
:evaluator evaluator
:read read
:parser parser}]
(def f (if (= (type path) :core/file)
path
(def f (case (type path)
:core/file path
:core/stream path
(file/open path :rb)))
(def path-is-file (= f path))
(default env (make-env))
@ -2612,7 +2613,7 @@
(put env :source (or src (if-not path-is-file spath path)))
(var exit-error nil)
(var exit-fiber nil)
(defn chunks [buf _] (file/read f 4096 buf))
(defn chunks [buf _] (:read f 4096 buf))
(defn bp [&opt x y]
(when exit
(bad-parse x y)
@ -2654,7 +2655,7 @@
:read read
:parser parser
:source (or src (if path-is-file "<anonymous>" spath))}))
(if-not path-is-file (file/close f))
(if-not path-is-file (:close f))
(when exit-error
(if exit-fiber
(propagate exit-error exit-fiber)

View File

@ -192,4 +192,11 @@
(assert (= (math/gcd 462 1071) 21) "math/gcd 1")
(assert (= (math/lcm 462 1071) 23562) "math/lcm 1")
# Evaluate stream with `dofile`
(def [r w] (os/pipe))
(:write w "(setdyn :x 10)")
(:close w)
(def stream-env (dofile r))
(assert (= (stream-env :x) 10) "dofile stream 1")
(end-suite)