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
17
17
* Removed implicit support for single-use iterables in sequences, and introduced ` iterator-seq ` to expliciltly handle them (#1192 )
18
18
* ` basilisp.core/str ` now delegates to the builtin Python ` str ` in all cases except for customizing the string output for builtin Python types (#1237 )
19
19
* 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 )
20
21
21
22
### Fixed
22
23
* 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 4120
4120
;; Async Macros ;;
4121
4121
;;;;;;;;;;;;;;;;;;
4122
4122
4123
- (defmacro afor
4123
+ (defmacro for-async
4124
4124
"Repeatedly execute ``body`` while the binding name is repeatedly rebound to
4125
4125
successive values from the asynchronous iterable.
4126
4126
4127
4127
.. warning::
4128
4128
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."
4130
4130
[binding & body]
4131
4131
(if (operator/ne 2 (count binding))
4132
4132
(throw
4144
4144
(catch python/StopAsyncIteration _
4145
4145
val#))))))
4146
4146
4147
- (defmacro awith
4147
+ (defmacro with-async
4148
4148
"Evaluate ``body`` within a ``try`` / ``except`` expression, binding the named
4149
4149
expressions as per Python's async context manager protocol spec (Python's
4150
4150
``async with`` blocks).
4151
4151
4152
4152
.. warning::
4153
4153
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."
4155
4155
[bindings & body]
4156
4156
(let [binding (first bindings)
4157
4157
expr (second bindings)]
Original file line number Diff line number Diff line change 9
9
(asyncio/set-event-loop loop)
10
10
(.run-until-complete loop (apply f args))))
11
11
12
- (deftest awith -test
12
+ (deftest with-async -test
13
13
(testing "base case"
14
14
(let [get-val (contextlib/asynccontextmanager
15
15
(fn ^:async get-val
16
16
[]
17
17
(yield :async-val)))
18
18
val-ctxmgr (fn ^:async yield-val
19
19
[]
20
- (awith [v (get-val)]
21
- v))]
20
+ (with-async [v (get-val)]
21
+ v))]
22
22
(is (= :async-val (async-to-sync val-ctxmgr))))))
23
23
24
- (deftest afor -test
24
+ (deftest for-async -test
25
25
(testing "base case"
26
26
(let [get-vals (fn ^:async get-vals
27
27
[]
30
30
val-loop (fn ^:async val-loop
31
31
[]
32
32
(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)]
36
36
[@a res]))]
37
37
(is (= [[0 1 2 3 4] 4] (async-to-sync val-loop))))))
You can’t perform that action at this time.
0 commit comments