Dan Sugalski <[EMAIL PROTECTED]> writes: > At 11:55 PM +0100 10/3/03, Piers Cawley wrote: >>Dan Sugalski <[EMAIL PROTECTED]> writes: >> >>> On Thu, 2 Oct 2003, Mark A. Biggar wrote: >>> >>>> Austin Hastings wrote: >>> >>>> > But that imposes <C>eval()</C> pretty frequently. Better to provide >>>> > some lower-level hackish way to agglutinate Blocks. >>>> >>>> >>>> Isn't this one of the prime examples of why CPS is being use, it allows >>>> for Tail Recursion Optimization. With TRO all your worries about >>>> overhead do to the wrap go away. >>> >>> This isn't why CPS is being used under the hood. (Nothing in perl 6 >>> propmted CPS) I wouldn't necessarily count on being able to do tail calls >>> here either, as they potentially alter the semantics, or at least the >>> introspectable environment, of the program as they make frames go away. >> >>I'm vaguely hoping that modules will be able to declare that they >>don't need to access a 'strict' caller and that they'll be happy >>with a return from caller that skips any tail calls. Then, if the >>Perl 6 compiler sees that all modules in play have declared >>themselves in this fashion it'll use optimized tail calls. However, >>thinking about that I'm not entirely sure how it could be done with a >>single pass compiler. > > I think it's reasonable to allow you to mark your subs as being able > to be tail-called out of. Subs with no lexical variables should be > safe to call out of as well, though that's a bit dodgier. OTOH, it's > not like too many folks walk up their call chain.
Actually, that makes a good deal more sense than my suggestion. As for hook functions, they probably want to hide themselves from C<caller> anyway, or hooking a single function in a call chain could cause introspective programs to fall over.