develooper Front page | perl.perl6.language | Postings from June 2006

[svn:perl6-synopsis] r9718 - doc/trunk/design/syn

From:
audreyt
Date:
June 26, 2006 14:28
Subject:
[svn:perl6-synopsis] r9718 - doc/trunk/design/syn
Message ID:
20060626212749.E695FD0F37@x12.develooper.com
Author: audreyt
Date: Mon Jun 26 14:27:49 2006
New Revision: 9718

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

Log:
* S06: This is invalid syntax:

    for @list sub { ... }

  because statement control only admins pointy or bare blocks.
  Since pointies and anonymous subs are actually very dissimilar
  (for "return" handling etc), we don't show the translation anymore

Modified: doc/trunk/design/syn/S06.pod
==============================================================================
--- doc/trunk/design/syn/S06.pod	(original)
+++ doc/trunk/design/syn/S06.pod	Mon Jun 26 14:27:49 2006
@@ -140,11 +140,13 @@
 given traits.  Syntactically a pointy sub is parsed exactly like a
 bare block.
 
-    $sq = -> $val { $val**2 };  # Same as: $sq = sub ($val) { $val**2 };
+    my $sq = -> $val { $val**2 };
+    say $sq(10); # 100
 
-    for @list -> $elem {        # Same as: for @list sub ($elem) {
-        print "$elem\n";        #              print "$elem\n";
-    }                           #          }
+    my @list = 1..3;
+    for @list -> $elem {
+        say $elem; # prints "1\n2\n3\n"
+    }
 
 It also behaves like a block with respect to control exceptions.  If you
 C<return> from within a pointy sub, it will return from the innermost



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About