On Sat, Apr 9, 2022 at 3:04 PM Henry Rich <[email protected]> wrote:
>
> A pyx looks on the outside like any other box. You can pass it as an
> argument. But as soon as you look inside it, your thread is blocked
> until the task producing the pyx's value has completed. Then you see the
> value, and your thread continues.
This is an exciting addition to J. The pyx design is elegant. I recently
spent some time studying R's implementation of futures, which is built upon
delayedAssign[1]. The semantics of R futures are similar - querying a value
of a non-resolved future will block the call[2].
R futures support checking to see if the future is resolved (or pyx in this
case) with a resolved() function
Is this supported in 4 T. ? Admittedly, I could not figure out how to call
4. T and have it produce a result. NuVoc seems to suggest that 4 T. can be
used to check on the status of pyxs but I'm not sure I'm interpreting it
correctly.
0 T. ''
foo =: {{echo ('done waiting ',(": y), ' seconds') [ (6!:3) y}} t.'' 5
4 T. ''
4 T. <"0 i.2
done waiting 5 seconds
I was thinking 4. T. '' would show something?
I saw the test case while researching this and it looks similar and this
works:
1 -
https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/delayedAssign
2 - https://github.com/HenrikBengtsson/future/blob/develop/R/future.R#L27
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm