-
Notifications
You must be signed in to change notification settings - Fork 581
[PATCH] Document for(;;) and while() in perlsyn #13895
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
Comments
From [email protected]for(;;) and while() do not appear to be documented in core; attached Summary of my perl5 (revision 5 version 20 subversion 0) configuration: Characteristics of this binary (from libperl): |
From [email protected]0001-Document-empty-conditional-in-for-while.patchFrom 62b13428938b1bde786bf346daacb1b5069dd610 Mon Sep 17 00:00:00 2001
From: Peter Martini <[email protected]>
Date: Mon, 2 Jun 2014 07:16:59 -0400
Subject: [PATCH] Document empty conditional in for/while
An empty conditional in both for and while has been treated
as true since perl 1.0. This has a clear analogue in C/C++
in the case of for(;;), but while() is not legal C and should
be documented.
---
pod/perlsyn.pod | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod
index 244372c..cea4d50 100644
--- a/pod/perlsyn.pod
+++ b/pod/perlsyn.pod
@@ -429,6 +429,21 @@ those variables is exactly the C<for> loop (the body of the loop
and the control sections).
X<my>
+As a special case, if the test in the C<for> loop (or the corresponding
+C<while> loop) is empty, it is treated as true. That is, both
+
+ for (;;) {
+ ...
+ }
+
+and
+
+ while () {
+ ...
+ }
+
+are treated as infinite loops.
+
Besides the normal array index looping, C<for> can lend itself
to many other interesting applications. Here's one that avoids the
problem you get into if you explicitly test for end-of-file on
--
1.9.1
|
From @jkeenanOn Mon Jun 02 04:23:46 2014, pcm wrote:
Seems reasonable to me. Any objection to applying? Thank you very much. |
The RT System itself - Status changed from 'new' to 'open' |
From @khwilliamsonOn Mon Jun 02 13:40:32 2014, jkeenan wrote:
+1 to applying |
@jkeenan - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#122015 (status was 'resolved')
Searchable as RT122015$
The text was updated successfully, but these errors were encountered: