Variables in pipelines

Rémi Forax forax at univ-mlv.fr
Wed Aug 15 14:46:15 PDT 2012


On 08/15/2012 10:35 PM, Jose wrote:
> OK thanks,
>
> I was dreaming with a super pipeline that was more than a mere sequence of
> operations, maybe nothing from this world.

If you start here, you know that you will end up with pipelines like the 
ones used by Tomcat, Grizzly, Spring, etc that merely require users to 
tag each variables with an annotation defining the scope.
So these kinds of pipelines while powerful are more a framework thing 
than a java.util thing.

Rémi

> -----Mensaje original-----
> De: Brian Goetz [mailto:brian.goetz at oracle.com]
> Enviado el: miércoles, 15 de agosto de 2012 21:50
> Para: Jose
> CC: lambda-dev at openjdk.java.net
> Asunto: Re: Variables in pipelines
>
> One thing you could do here is use "mapped", which is an operation on a
> linear stream that produces a MapStream:
>
>     rects.mapped(r1 -> rotate(alpha)) // produces stream of (r1, rotated)
>          .tap((r1, r2) -> ...);
>
> Now downstream stages have access to both.
>
> (What you're specifically asking for doesn't really make linguistic sense;
> r1 is like a method parameter, which isn't available outside that method's
> scope.)
>
> On 8/15/2012 3:33 PM, Jose wrote:
>> Let suppose I want to do some operations in a stream of rectangles:
>> rotate them and finding the intersection of the rotateded rectangles
>> with the original ones:
>>
>>               
>> rects.map(r1->rotate(alpha)).tap(r2)->r2.intersection(r1);
>>
>>
>> Here "tap" refers to the discusion on forEach
>> http://mail.openjdk.java.net/pipermail/lambda-dev/2012-August/005463.h
>> tml
>>
>> The problem is that being r1 a dummy variable, its reference is lost
>> in the next link of the chain.
>>
>> It would be possible and desirable to keep the references of the
>> variables inside a pipeline?.
>>
>> Maybe you can use BiMapper to keep trace of another variable, but the
>> code would be much more cumbersome.
>> Not to say if you want to reuse two o more variables along the pipeline.
>>
>>
>>
>



More information about the lambda-dev mailing list