mirror of
https://github.com/janet-lang/janet
synced 2024-06-26 07:03:16 +00:00
Update changelog and allow evaluating streams with dofile.
This commit is contained in:
parent
34c7f15d6d
commit
9cc4e48124
|
@ -2,6 +2,12 @@
|
||||||
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
|
||||||
|
- 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.
|
- Deadlocked channels will no longer exit early - instead they will hang, which is more intuitive.
|
||||||
|
|
||||||
## 1.18.1 - 2021-10-16
|
## 1.18.1 - 2021-10-16
|
||||||
|
|
|
@ -2590,7 +2590,7 @@
|
||||||
@{})
|
@{})
|
||||||
|
|
||||||
(defn dofile
|
(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
|
:evaluator, :read, and :parser are passed through to the underlying
|
||||||
run-context call. If exit is true, any top level errors will trigger a
|
run-context call. If exit is true, any top level errors will trigger a
|
||||||
call to (os/exit 1) after printing the error.`
|
call to (os/exit 1) after printing the error.`
|
||||||
|
@ -2602,8 +2602,9 @@
|
||||||
:evaluator evaluator
|
:evaluator evaluator
|
||||||
:read read
|
:read read
|
||||||
:parser parser}]
|
:parser parser}]
|
||||||
(def f (if (= (type path) :core/file)
|
(def f (case (type path)
|
||||||
path
|
:core/file path
|
||||||
|
:core/stream path
|
||||||
(file/open path :rb)))
|
(file/open path :rb)))
|
||||||
(def path-is-file (= f path))
|
(def path-is-file (= f path))
|
||||||
(default env (make-env))
|
(default env (make-env))
|
||||||
|
@ -2612,7 +2613,7 @@
|
||||||
(put env :source (or src (if-not path-is-file spath path)))
|
(put env :source (or src (if-not path-is-file spath path)))
|
||||||
(var exit-error nil)
|
(var exit-error nil)
|
||||||
(var exit-fiber 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]
|
(defn bp [&opt x y]
|
||||||
(when exit
|
(when exit
|
||||||
(bad-parse x y)
|
(bad-parse x y)
|
||||||
|
@ -2654,7 +2655,7 @@
|
||||||
:read read
|
:read read
|
||||||
:parser parser
|
:parser parser
|
||||||
:source (or src (if path-is-file "<anonymous>" spath))}))
|
: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
|
(when exit-error
|
||||||
(if exit-fiber
|
(if exit-fiber
|
||||||
(propagate exit-error exit-fiber)
|
(propagate exit-error exit-fiber)
|
||||||
|
|
|
@ -192,4 +192,11 @@
|
||||||
(assert (= (math/gcd 462 1071) 21) "math/gcd 1")
|
(assert (= (math/gcd 462 1071) 21) "math/gcd 1")
|
||||||
(assert (= (math/lcm 462 1071) 23562) "math/lcm 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)
|
(end-suite)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user