> -----Original Message----- > From: Jonathan Scott Duff [mailto:[EMAIL PROTECTED] > On Thu, Oct 02, 2003 at 11:39:20AM +0100, Dave Mitchell wrote: > > On Thu, Oct 02, 2003 at 04:15:06AM -0600, Luke Palmer wrote: > > > So the question is: What happens when indexof isn't on the call chain, > > > but that inner closure is? > > > > But how can the inner closure be called if not via indexof? > > I believe that's exactly what Luke's original example was > illustrating. > > On Thu, Oct 02, 2003 at 01:59:26AM -0600, Luke Palmer wrote: > > So, I must ask, what does this do: > > > > sub foo() { > > return my $self = { > > print "Block"; > > return $self; > > } > > } > > foo() returns a closure that contains code that returns from the foo() > subroutine (the line that says "return $self") When that closure is > then called ... > > > my $block = foo; > > print "Main"; > > $block(); > > ... foo() is no longer executing. > > > That is, the block returns from a function that's not currently > > executing. > > > > Will the output be: a) > > > > Can't 'return' from closure Block > > > > b) > > > > Main > > Block > > Can't 'return' from closure Block > > > > (just like (a) but runtime) > > c) > > > > Main > > Block > > > > (the block's return returns from the main program, or whatever function > > is currently executing) > > > > d) > > > > Main > > Block > > Main > > Block > > Main > > Block > > ... > > > > (the block closes over the function's return continuation) > > I would expect (a) to happen, but (d) has some interesting > possibilities.
I hope not. Otherwise the ability to use anonymous blocks would be severely impaired. If there's a list of keywords that can't be used in anonymous blocks, that's a pretty severe limitation. And really, is this any worse than an anonymous block that throws exceptions? Speaking to the practical side, I have written code that has to disentangle itself from the failure of a complex startup sequence. I'd love to be able to build a dynamic exit sequence. (In fact, being able to do <C>&block .= { more_stuff(); };</C> is way up on my list...) =Austin