> -----Original Message-----
> From: Luke Palmer [mailto:[EMAIL PROTECTED]
> Sent: Thursday, October 02, 2003 10:23 PM
> To: Jeff Clites
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: The Block Returns
>
>
> Jeff Clites writes:
> > >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...)
> >
> > I've wanted to do that sort of thing before, but it seems simpler
> > (conceptually and practically) to build up an array of cleanup
> > subs/blocks to execute in sequence, rather than to have a .= for
> > blocks. (Another reason it's handy to keep them separate is in cases in
> > which each needs to return some information--maybe a status which
> > determines whether to proceed, etc.)
>
> But this is already supported, in its most powerful form:
>
> wrap &block: { call; other_stuff() }
Hmm, no.
That does a call, which presumes a return, which burns up who-knows-how-many mips.
Given that the compiler is being forced to remember the code in case someone overloads
the semicolon operator, or whatever, I don't think it's unreasonable to catenate the
.source values of various blocks, and that seems a reasonable behavior for
<C>infix:.=(Block, Block) {...}</C>.
Especially since the other way turns into:
macro atexit(Block $b) {
get_the_current_sub().eval("my &block = {};")
unless defined █
wrap &block: { call; $b(); };
}
Which makes two calls per additional whosit.
Frankly, I think I'd rather see:
macro atexit($code) is parsed(/{ <Perl6.line>* }/) {
get_the_current_sub().eval("my $block;")
unless defined $block;
$block .= $code;
}
macro return($retval) {
eval($block) if defined $block;
leave Routine, $retval;
}
But that imposes <C>eval()</C> pretty frequently. Better to provide some lower-level
hackish way to agglutinate Blocks.
=Austin