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

Document return interaction with do BLOCK #16841

Closed
p5pRT opened this issue Feb 5, 2019 · 5 comments · Fixed by #17375
Closed

Document return interaction with do BLOCK #16841

p5pRT opened this issue Feb 5, 2019 · 5 comments · Fixed by #17375

Comments

@p5pRT
Copy link

p5pRT commented Feb 5, 2019

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

Searchable as RT133826$

@p5pRT
Copy link
Author

p5pRT commented Feb 5, 2019

From @Grinnz

The documentation for return currently states that it will return from
eval, do FILE, and sort blocks, and not from grep or map blocks, but
doesn't state its interaction with do BLOCK blocks. The attached patch will
specify this.

-Dan

(Perl)

@p5pRT
Copy link
Author

p5pRT commented Feb 5, 2019

From @Grinnz

Patch attached.

@p5pRT
Copy link
Author

p5pRT commented Feb 5, 2019

From @Grinnz

perl_return_do.patch
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 973a2612d7..f6b8788849 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -6682,8 +6682,8 @@ X<return>
 
 Returns from a subroutine, L<C<eval>|/eval EXPR>,
 L<C<do FILE>|/do EXPR>, L<C<sort>|/sort SUBNAME LIST> block or regex
-eval block (but not a L<C<grep>|/grep BLOCK LIST> or
-L<C<map>|/map BLOCK LIST> block) with the value
+eval block (but not a L<C<grep>|/grep BLOCK LIST>,
+L<C<map>|/map BLOCK LIST>, or L<C<do BLOCK>|/do BLOCK> block) with the value
 given in EXPR.  Evaluation of EXPR may be in list, scalar, or void
 context, depending on how the return value will be used, and the context
 may vary from one execution to the next (see

@p5pRT
Copy link
Author

p5pRT commented Feb 5, 2019

From @Grinnz

Reformatted with git format-patch.

@p5pRT
Copy link
Author

p5pRT commented Feb 5, 2019

From @Grinnz

0001-Mention-that-you-cannot-return-from-do-BLOCK.patch
From 3f8b2d87be3237ce711d21e85232442493fb1d47 Mon Sep 17 00:00:00 2001
From: Dan Book <grinnz@grinnz.com>
Date: Tue, 5 Feb 2019 17:41:18 -0500
Subject: [PATCH] Mention that you cannot return from do BLOCK

---
 pod/perlfunc.pod | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 973a2612d7..f6b8788849 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -6682,8 +6682,8 @@ X<return>
 
 Returns from a subroutine, L<C<eval>|/eval EXPR>,
 L<C<do FILE>|/do EXPR>, L<C<sort>|/sort SUBNAME LIST> block or regex
-eval block (but not a L<C<grep>|/grep BLOCK LIST> or
-L<C<map>|/map BLOCK LIST> block) with the value
+eval block (but not a L<C<grep>|/grep BLOCK LIST>,
+L<C<map>|/map BLOCK LIST>, or L<C<do BLOCK>|/do BLOCK> block) with the value
 given in EXPR.  Evaluation of EXPR may be in list, scalar, or void
 context, depending on how the return value will be used, and the context
 may vary from one execution to the next (see
-- 
2.20.1

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

Successfully merging a pull request may close this issue.

1 participant