> > 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: > > Prematurely sent while copy/pasting -- sorry
This outputs something (similar to test case at https://github.com/jsoftware/jsource/commit/eb5c004883dab55b7bb64cc66d5ec0dc753dd54a#diff-6809efa22d5939ea45f5c05f7e5b7b954fb6af7b67b78f65f650600b8579f581R116), but I'm not sure why it outputs the result of 4 T. '' with thread id 1, but my first example above does not 4 T. (3&T.@'')@{{echo ('done waiting ',(": y), ' seconds') [ (6!:3) y}} t.'' 5 > 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
