File tree Expand file tree Collapse file tree 3 files changed +12
-11
lines changed Expand file tree Collapse file tree 3 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717 * Removed implicit support for single-use iterables in sequences, and introduced ` iterator-seq ` to expliciltly handle them (#1192 )
1818 * ` basilisp.core/str ` now delegates to the builtin Python ` str ` in all cases except for customizing the string output for builtin Python types (#1237 )
1919 * Optimised mainstream seq-consuming functions by coercing their inputs into ` seq ` upfront (#1234 )
20+ * Renamed ` awhile ` and ` afor ` to ` while-async ` and ` for-async ` for improved clarity (#1248 )
2021
2122### Fixed
2223 * Fix a bug where protocols with methods with leading hyphens in the could not be defined (#1230 )
Original file line number Diff line number Diff line change 41204120;; Async Macros ;;
41214121;;;;;;;;;;;;;;;;;;
41224122
4123- (defmacro afor
4123+ (defmacro for-async
41244124 "Repeatedly execute ``body`` while the binding name is repeatedly rebound to
41254125 successive values from the asynchronous iterable.
41264126
41274127 .. warning::
41284128
4129- The ``afor `` macro may only be used in an asynchronous function context."
4129+ The ``for-async `` macro may only be used in an asynchronous function context."
41304130 [binding & body]
41314131 (if (operator/ne 2 (count binding))
41324132 (throw
41444144 (catch python/StopAsyncIteration _
41454145 val#))))))
41464146
4147- (defmacro awith
4147+ (defmacro with-async
41484148 "Evaluate ``body`` within a ``try`` / ``except`` expression, binding the named
41494149 expressions as per Python's async context manager protocol spec (Python's
41504150 ``async with`` blocks).
41514151
41524152 .. warning::
41534153
4154- The ``awith `` macro may only be used in an asynchronous function context."
4154+ The ``with-async `` macro may only be used in an asynchronous function context."
41554155 [bindings & body]
41564156 (let [binding (first bindings)
41574157 expr (second bindings)]
Original file line number Diff line number Diff line change 99 (asyncio/set-event-loop loop)
1010 (.run-until-complete loop (apply f args))))
1111
12- (deftest awith -test
12+ (deftest with-async -test
1313 (testing "base case"
1414 (let [get-val (contextlib/asynccontextmanager
1515 (fn ^:async get-val
1616 []
1717 (yield :async-val)))
1818 val-ctxmgr (fn ^:async yield-val
1919 []
20- (awith [v (get-val)]
21- v))]
20+ (with-async [v (get-val)]
21+ v))]
2222 (is (= :async-val (async-to-sync val-ctxmgr))))))
2323
24- (deftest afor -test
24+ (deftest for-async -test
2525 (testing "base case"
2626 (let [get-vals (fn ^:async get-vals
2727 []
3030 val-loop (fn ^:async val-loop
3131 []
3232 (let [a (atom [])
33- res (afor [v (get-vals)]
34- (swap! a conj v)
35- v)]
33+ res (for-async [v (get-vals)]
34+ (swap! a conj v)
35+ v)]
3636 [@a res]))]
3737 (is (= [[0 1 2 3 4] 4] (async-to-sync val-loop))))))
You can’t perform that action at this time.
0 commit comments