On Mon Aug 10 17:19:45 2015, alex.jakime...@gmail.com wrote:
> Code:
> sub foo { say 'X' };
> &foo.wrap:{ callsame; callsame; callsame };
> foo;
> 
> Result:
> X
> 
> I expected this:
> X
> X
> X
> 
Then you expected wrong. Discussion here:

http://irclog.perlgeek.de/perl6/2015-11-12#i_11527573

This ticket did uncover that there isn't a way to actually do what you wanted, 
though, so we have nextcallee, which does. I've added a test for that in 
S12-methods/defer-call.t. The remaining open question I've asked (waiting for 
answer) is what callsame should do on an exhausted dispatch iterator.

> Another interesting code snippet:
> sub foo { say 'X' };
> &foo.wrap:{ callsame; callsame; nextsame; say 'y' };
> foo;
> 
> Which, surprisingly, prints this:
> X
> y
> 
I think it's dubious that nextsame lets control go on to the say 'y' even if 
the iterator is exhausted, so asked about this one too. Will update tickets and 
tests with the answers.

/jnthn

Reply via email to