On Sun, 18 Dec 2016 08:44:31 -0800, moritz wrote:
> Hi,
> 
> On 18.12.2016 15:35, Wenzel Peppmeyer (via RT) wrote:
> > # New Ticket Created by  Wenzel Peppmeyer
> > # Please include the string:  [perl #130371]
> > # in the subject line of all future correspondence about this issue.
> > # <URL: https://rt.perl.org/Ticket/Display.html?id=130371 >
> >
> >
> > my &block = { say 'returning from &block'; return };
> > sub returned-from(&code) { say 'enter returned-from'; code; say
> > 'leave returned-from' };
> > sub forcing-a-return { returned-from &block };
> > forcing-a-return;
> >
> > # OUTPUT«enter returned-from␤returning from &block␤Attempt to return
> > outside of any Routine␤  in block <unit> at <tmp> line 1␤␤»
> > # expected
> > # OUTPUT«enter returned-from␤returning from &block␤»
> > # this may be a regression caused by
> > a4ca12afa30be4ce5dfc3602f54a5563d069ffa5
> 
> I'm pretty sure that's not a bug; &return is supposed to be tied to
> the
> lexically outer Routine, and in this example, there is no lexically
> outer Routine, so the error message is valid.
> 
> Cheers,
> Moritz


Isn't this just throwing a CX::Return control exception and thus should work? 
How/when does the tying to the lexically outer Routine happen?

Such method works for other control exceptions, like, CX::Last:

my &block = { say 'returning from &block'; last };
sub last-from(&code) { say 'enter returned-from'; code; say 'leave 
returned-from' };
for ^6 {
    .say;
    last-from &block;
}

# OUTPUT:
# 0
# enter returned-from
# returning from &block

Reply via email to