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

.&foo form differs from foo($_) when routine throws control exceptions #6321

Open
p6rt opened this issue Jun 3, 2017 · 1 comment
Open

.&foo form differs from foo($_) when routine throws control exceptions #6321

p6rt opened this issue Jun 3, 2017 · 1 comment
Labels
LTA

Comments

@p6rt
Copy link

@p6rt p6rt commented Jun 3, 2017

Migrated from rt.perl.org#131504 (status was 'new')

Searchable as RT131504$

@p6rt
Copy link
Author

@p6rt p6rt commented Jun 3, 2017

From @zoffixznet

I assumed the .&foo form was just a nicer way of writing foo($_), however they differ in that
the thrown control exception doesn't go far enough in .&foo form and it doesn't actually
return from the routine with things like .&fail and .&return

  <Zoffix__> m​: sub { 'foo'.&fail; 42 }().^name.say
  <camelia> rakudo-moar 64e898​: OUTPUT​: «foo␤ in sub at <tmp> line 1␤ in block <unit> at <tmp> line 1␤␤Actually thrown at​:␤ in sub at <tmp> line 1␤ in block <unit> at <tmp> line 1␤␤»
  <Zoffix__> m​: sub { fail 'foo'; 42 }().^name.say
  <camelia> rakudo-moar 64e898​: OUTPUT​: «Failure␤»

  <Zoffix__> m​: sub { return 'foo'; 42 }().^name.say
  <camelia> rakudo-moar 64e898​: OUTPUT​: «Str␤»
  <Zoffix__> m​: sub { 'foo'.&return; 42 }().^name.say
  <camelia> rakudo-moar 64e898​: OUTPUT​: «Int␤»

@p6rt p6rt added the LTA label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.