Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callsame does not work more than once (callsame; callsame; callsame;) #4465

Closed
p6rt opened this issue Aug 11, 2015 · 5 comments
Closed

callsame does not work more than once (callsame; callsame; callsame;) #4465

p6rt opened this issue Aug 11, 2015 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Aug 11, 2015

Migrated from rt.perl.org#125783 (status was 'resolved')

Searchable as RT125783$

@p6rt
Copy link
Author

p6rt commented Aug 11, 2015

From @AlexDaniel

Code​:
sub foo { say 'X' };
&foo.wrap​:{ callsame; callsame; callsame };
foo;

Result​:
X

I expected this​:
X
X
X

Another interesting code snippet​:
sub foo { say 'X' };
&foo.wrap​:{ callsame; callsame; nextsame; say 'y' };
foo;

Which, surprisingly, prints this​:
X
y

IRC log​: http://irclog.perlgeek.de/perl6/2015-08-10#i_11036336 and
http://irclog.perlgeek.de/perl6/2015-08-11#i_11036346

@p6rt
Copy link
Author

p6rt commented Nov 13, 2015

From @jnthn

On Mon Aug 10 17​:19​:45 2015, alex.jakimenko@​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

@p6rt
Copy link
Author

p6rt commented Nov 13, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Nov 17, 2015

From @jnthn

On Fri Nov 13 09​:05​:08 2015, jnthn@​jnthn.net wrote​:

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.

Larry answered that callsame/callwith returning Nil is the right thing, so those semantics stand.

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.

We now will never reach that 'y' even if we don't have anywhere to go; the nextsame will call a return of Nil.

Tests for these updated semantics added in S12-methods/defer-[call|next].t.

/jnthn

@p6rt p6rt closed this as completed Nov 17, 2015
@p6rt
Copy link
Author

p6rt commented Nov 17, 2015

@jnthn - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant