This is (I suspect) the intent of the perl6 take/gather "at some future point in time", but currently it take is simply a push to a hidden array and once all the values have been collected, the gather subroutine iterates over that array popping them off as it goes.
This is incorrect. The gather/take implementations in Niecza and Rakudo are lazy and have always been.
It could also be done using green (user space) threading; or continuations; or go-style goroutines. And if you believe the P6 specs, it intends to support all of those and more.
But, when (to my knowledge) there has been no (ZERO) attempt to provide and flavour of multitasking in any of the p6-ish interpreters, it doesn't look likely. YOU cannot add this stuff successfully as an after thought; you have to architect it in from the ground up or you end up with iThreads or similar.
The general framework for P6's concurrency and parallel processing capabilities was designed many years ago. The design wisely abstracts across backends with varying concurrency primitives (CLR, JVM, Parrot, and other VMs). Implementations have then followed this design.
Pugs was written in Haskell so had Haskell's capabilities underneath from day 1.
Rakudo was born with usable continuations and coroutines underneath it on day 1 of its existence (because "Parrot is based on continuations"). The threads story is more complex; interested parties would best research for themselves.
"gather/take has controlled the design of Niecza from day 1". Niecza has continuations, coroutines, and threads.
|Comment on Re^4: Haskell vs Perl 6 (was Re: Capturing parenthesis and grouping square brackets)|