On Tue, 12 Nov 2002 14:30:24 +0000, Peter Haworth wrote:
> So to get the same yield context, each call to the coroutine has to be from
> the same calling frame. If you want to get several values from the same
> coroutine, but from different calling contexts, can you avoid the need to
> wrap it in a closure?
I'm an idiot. Why not make the closure a coroutine itself?
sub consume(@bar){
my $next=sub{ yielf $_ for @bar; return; };
while my $val = $next() {
do_stuff($val,$next);
}
}
> sub do_stuff($val,$next){
> ...
> if $val ~~ something_or_other() {
> my $quux = $next();
> ...
> }
> }
>
--
Peter Haworth [EMAIL PROTECTED]
"The term `Internet' has the meaning given that term in
section 230(f)(1) of the Communications Act of 1934."
-- H.R. 3028, Trademark Cyberpiracy Prevention Act