Author: larry
Date: Fri Sep 15 08:38:58 2006
New Revision: 12006

Modified:
   doc/trunk/design/syn/S04.pod

Log:
smartlinkable discussion of bindables on while and repeat while


Modified: doc/trunk/design/syn/S04.pod
==============================================================================
--- doc/trunk/design/syn/S04.pod        (original)
+++ doc/trunk/design/syn/S04.pod        Fri Sep 15 08:38:58 2006
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall <[EMAIL PROTECTED]>
   Date: 19 Aug 2004
-  Last Modified: 1 Sep 2006
+  Last Modified: 15 Sep 2006
   Number: 4
-  Version: 38
+  Version: 39
 
 This document summarizes Apocalypse 4, which covers the block and
 statement syntax of Perl.
@@ -190,6 +190,20 @@
        ...
     }
 
+You may optionally bind the result of the conditional expression to a
+parameter of the block:
+
+    while something() -> $thing {
+       ...
+    }
+
+Nothing is ever bound implicitly, however, and many conditionals would
+simply bind True or False in an uninteresting fashion.  This mechanism
+is really only good for objects that know how to return a boolean
+value and still remain themselves.  In general, for most iterated
+solutions you should consider using a C<for> loop instead (see below).
+In particular, we now generally use C<for> to iterate filehandles.
+
 =head2 The C<repeat> statement
 
 Unlike in Perl 5, applying a statement modifier to a C<do> block is
@@ -242,6 +256,22 @@
        ...
       }
 
+As with an ordinary C<while>, you may optionally bind the result of
+the conditional expression to a parameter of the block:
+
+    repeat -> $thing {
+       ...
+    } while something();
+
+or
+
+    repeat while something() -> $thing {
+       ...
+    }
+
+Since the loop executes once before evaluating the condition, the
+bound parameter will be undefined that first time through the loop,
+
 =head2 The general loop statement
 
 The C<loop> statement is the C-style C<for> loop in disguise:

Reply via email to