HaloO, On Saturday, 9. August 2008 01:32:35 John M. Dlugosz wrote: > TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: > > If such a ReturnCapture could also be > > preliminary of some kind, then lvalue subs could be lazily resumed when > > the rvalue comes in. > > Can you elaborate on that? I don't follow.
The fundamental problem with lvalue methods is that some of them want to have control *after* they returned their value. One ugly way to achieve this is how it is usually done in C++ or Java: the rvalue is a parameter of the method. So instead of $obj.foo(1,2) = 3; #1 one writes $obj.foo(1,2,3); #2 which doesn't look like an lvalue method at all. And you can't use it in rvalue context as the former: my $x = $obj.foo(1,2); #3 Here the ReturnCapture collapses right away. But in #1 it could be resumed with rvalue 3. That is the invocation of .foo(1,2) resumes after the statement that produced the ReturnCapture. In the assignable mutators thread I proposed to call that statement 'yield'. To the function it behaves like the declaration of a variable that receives the value that is assigned later. To the outside it is the preliminary rvalue. If no assignment takes place no resumption is made. The new thing here is that one needs to write my $x = |$obj.foo(1,2); #4 to keep the ReturnCapture, and call it later either explicitly $x.resume(3); or implicitly $x = 3; Hope that helps, TSa. -- "The unavoidable price of reliability is simplicity" -- C.A.R. Hoare "Simplicity does not precede complexity, but follows it." -- A.J. Perlis 1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan