Author: autrijus
Date: Sat Apr  1 10:36:25 2006
New Revision: 8523

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

Log:
* S05: $/.() is now $$/.  $() still works as $$/, and we
  have @() %() forms that maps to @$/ and %$/.

Modified: doc/trunk/design/syn/S05.pod
==============================================================================
--- doc/trunk/design/syn/S05.pod        (original)
+++ doc/trunk/design/syn/S05.pod        Sat Apr  1 10:36:25 2006
@@ -13,9 +13,9 @@
 
    Maintainer: Patrick Michaud <[EMAIL PROTECTED]>
    Date: 24 Jun 2002
-   Last Modified: 25 Feb 2006
+   Last Modified: 1 Apr 2006
    Number: 5
-   Version: 12
+   Version: 13
 
 This document summarizes Apocalypse 5, which is about the new regex
 syntax.  We now try to call them "rules" because they haven't been
@@ -1120,18 +1120,18 @@
 
 =item *
 
-When called as a closure, a Match object evaluates to its underlying
+When used as a scalar, a Match object evaluates to its underlying
 result object.  Usually this is just the entire match string, but
 you can override that by calling C<return> inside a rule:
 
-    my $moose = m:{
+    my $moose = $(m:{
         <antler> <body>
         { return Moose.new( body => $<body>().attach($<antler>) ) }
         # match succeeds -- ignore the rest of the rule
-    }.();
+    });
 
-C<$()> is a shorthand for C<$/.()> or C<$/()>.  The result object
-may be of any type, not just a string.
+C<$()> is a shorthand for C<$($/)>.  The result object may be of any type,
+not just a string.
 
 You may also capture a subset of the match as the result object using
 the C<< <(...)> >> construct:
@@ -1149,8 +1149,8 @@
 
 This means that these two work the same:
 
-    / <moose> { $<moose>.() as Moose } /
-    / <moose> { $<moose>    as Moose } /
+    / <moose> { return $$<moose> as Moose } /
+    / <moose> { return $<moose>  as Moose } /
 
 =item *
 
@@ -1172,8 +1172,13 @@
 
      $mystring = "{ m:w/ (\S+) => (\S+)/[] }";
 
+Or cast it into an array:
+
+     $mystring = "@( m:w/ (\S+) => (\S+)/ )";
+
 Note that, as a scalar variable, C<$/> doesn't automatically flatten
-in list context.  Use C<@$/> or C<$/[]> to flatten as an array.
+in list context.  Use C<@()> as a shorthand for C<@($/)> to flatten
+the positional captures under list context.
 
 =item *
 
@@ -1185,8 +1190,8 @@
 capture datatypes.)
 
 Note that, as a scalar variable, C<$/> doesn't automatically flatten
-in list context.  Use C<%$/> or C<$/{}> to flatten as a hash, or bind
-it to a variable of the appropriate type.
+in list context.  Use C<%()> as a shorthand for C<%($/)> to flatten as a
+hash, or bind it to a variable of the appropriate type.
 
 =item *
 

Reply via email to