You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NEWS.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,9 @@
1
-
# nanonext 0.2.0.9007 (development)
1
+
# nanonext 0.2.0.9008 (development)
2
2
3
3
#### New Features
4
4
5
5
* Aio values `$result`, `$data` and `$raw` now resolve automatically without requiring `call_aio()`. Access the values directly and an 'unresolved' logical NA will be returned if the Aio operation is yet to complete.
6
6
*`unresolved()` added as an auxiliary function to query whether an Aio is unresolved, for use in control flow statements.
7
-
* Implements the Deferred Evaluation Pipe `%>>%` and Meanwhile / Concurrency Pipe `%~%` for working with potentially unresolved values.
8
7
* Integer error values generated by receive functions are now classed 'errorValue'. `is_error_value()` helper function included.
9
8
*`is_nul_byte()` added as a helper function for request/reply setups.
10
9
*`survey_time()` added as a convenience function for surveyor/respondent patterns.
{nanonext} implements a deferred evaluation pipe `%>>%` for working with potentially unresolved values.
262
-
263
-
Simply pipe the value forward into a function or series of functions and it either evaluates or returns an 'unresolvedExpr'.
264
-
265
-
The result may be queried at `$data`, which will return another 'unresolvedExpr' whilst unresolved. However when the original value resolves, the 'unresolvedExpr' will simultaneously resolve into a 'resolvedExpr', for which the evaluated result will be available at `$data`.
266
-
267
-
It is possible to use `unresolved()` around a 'unresolvedExpr' or its `$data` element to test for resolution, as in the example below.
268
-
269
-
The pipe operator semantics are similar to R's base pipe `|>`:
270
-
271
-
`x %>>% f` is equivalent to `f(x)` <br />
272
-
`x %>>% f()` is equivalent to `f(x)` <br />
273
-
`x %>>% f(y)` is equivalent to `f(x, y)`
274
-
275
-
```{r pipe1}
276
-
277
-
s1 <- socket("pair", listen = "inproc://dep")
278
-
s2 <- socket("pair", dial = "inproc://dep")
279
-
280
-
# request an aysnc receive with no messages waiting
281
-
msg <- recv_aio(s2)
282
-
283
-
res <- msg$data %>>% c(2, 3) %>>% as.character()
284
-
res
285
-
unresolved(res$data)
286
-
287
-
# sending a message causes both 'msg' and 'res' to resolve
288
-
s <- send_aio(s1, 1)
289
-
unresolved(res)
290
-
res
291
-
res$data
292
-
293
-
close(s1)
294
-
close(s2)
295
-
296
-
```
297
-
298
-
[« Back to ToC](#table-of-contents)
299
-
300
-
### Meanwhile (Concurrency) Pipe
301
-
302
-
The deferred evaluation pipe sequence may be terminated with a meanwhile (or concurrency) pipe `%~%` which:
303
-
304
-
(i) provides certainty of the return value, which will always be the evaluated result rather than a 'resolvedExpr'
305
-
306
-
(ii) makes it convenient to write concurrent code which runs whilst the expression is resolving
307
-
308
-
`x %~% expr`
309
-
310
-
is equivalent to the following expression, finally returning x:
311
-
312
-
`if (unresolved(x)) while (unresolved(x <- x$data)) {expr}; x`
0 commit comments