Two questions about forEach

Rémi Forax forax at univ-mlv.fr
Thu Aug 9 05:46:08 PDT 2012


On 08/09/2012 02:30 PM, Gregg Wonderly wrote:
> On 8/9/2012 2:22 AM, Mike Duigou wrote:
>> Does every item get refreshed in order to complete findFirst? Do you really
>> want findFirst to inspect every element? The semantics and efficiency are
>> important.
> Yes, but I still really feel that "guessing" and "optimizing" how efficiency
> will be achieved, before we've had this in the wild, is completely premature.
>
> I know that this feels, right now, like a lazy programming style, which then
> becomes an inefficient run time execution.  But, do we really want to set, in
> stone, that foreach, can't return the stream?
>
> Gregg Wonderly
>

It's part of the design to segregate lazy and eager operations  and 
these choices are (or will be) reflected in the doc of the API.

So the question is more do we need a lazy dual of forEach (tap as 
suggested by Craig).
Nonetheless, forEach is and will stay eager.

Rémi



More information about the lambda-dev mailing list