Few may know that (in the devel trunk) I have added the (experimental) "yield"
and "yieldAppend" keywords to the loop construct:

If "yield" (and/or "yieldAppend") appears in a "for" loop, this loop is
automatically spawned on its own thread, and each element is generated on demand
(using WaitNeeded).  This is very much "like" what happens in Python.

I think "yield" is a good idea, but it should be supplemented with a means of
controlling the "batch" step described in my idea for "on-demand batch" stream
processing.  For example, let's imagine a "yieldBy" loop keyword that tells us
the desired batch size:

for
   I in 1..1000000
   yield : Yield
   yieldBy : 100
do
   {Yield I mod 27}
end

I think that the "yield" keyword is a nice addition to the "for" loop support,
in keeping with similar additions to e.g. Python.  "yieldBy" would allow us to
control how many elements to "Yield" before the thread actually suspends.

Cheers,

PS: another issue with "yield" support is that the stream being generated is
generated "safely" (i.e. with read-only variables).  This is quite expensive,
and maybe it would be worthwhile to (occasionally) turn this security feature
off in the interests of efficiency.  In practice, there are important, yet very
few, occasions where stream safety is paramount (because streams tend to be
intermediate data-structures that cannot be subverted).

-- 
Dr. Denys Duchier - IRI & LIFL - CNRS, Lille, France
+33 (0)6 25 78 25 74    http://www.lifl.fr/~duchier/
_________________________________________________________________________________
mozart-hackers mailing list                           
[email protected]      
http://www.mozart-oz.org/mailman/listinfo/mozart-hackers

Reply via email to