Author: lwall
Date: 2010-02-02 19:20:08 +0100 (Tue, 02 Feb 2010)
New Revision: 29620
Modified:
docs/Perl6/Spec/S05-regex.pod
docs/Perl6/Spec/S07-iterators.pod
Log:
[S05] more @@ whackage
[S07] define flat and slice methods in terms of get and getobj
Modified: docs/Perl6/Spec/S05-regex.pod
===================================================================
--- docs/Perl6/Spec/S05-regex.pod 2010-02-02 18:15:55 UTC (rev 29619)
+++ docs/Perl6/Spec/S05-regex.pod 2010-02-02 18:20:08 UTC (rev 29620)
@@ -453,7 +453,7 @@
$str = "abracadabra";
if $str ~~ m:overlap/ a (.*) a / {
- @substrings = @@(); # bracadabr cadabr dabr br
+ @substrings = slice @(); # bracadabr cadabr dabr br
}
=item *
@@ -1056,11 +1056,11 @@
When you get tired of writing:
- token sigil { '$' | '@' | '@@' | '%' | '&' | '::' }
+ token sigil { '$' | '@' | '%' | '&' | '::' }
you can write:
- token sigil { < $ @ @@ % & :: > }
+ token sigil { < $ @ % & :: > }
as long as you're careful to put a space after the initial angle so that
it won't be interpreted as a subrule. With the space it is parsed
@@ -1076,7 +1076,6 @@
proto token sigil { }
multi token sigil:sym<$> { <sym> }
multi token sigil:sym<@> { <sym> }
- multi token sigil:sym<@@> { <sym> }
multi token sigil:sym<%> { <sym> }
multi token sigil:sym<&> { <sym> }
multi token sigil:sym<::> { <sym> }
@@ -3633,10 +3632,9 @@
Subcaptures are returned as a multidimensional list, which the user can
choose to process in either of two ways. If you refer to
-C<@()>, the multidimensionality is ignored and all the matches are returned
-flattened (but still lazily). If you refer to C<@@()>, you can
-get each individual sublist as a C<Capture> object. (That is, there is a
C<@@()>
-coercion operator that happens, like C<@()>, to default to C<$/>.)
+C<@().flat> (or just use C<@()> in a flat list context), the
multidimensionality is ignored and all the matches are returned
+flattened (but still lazily). If you refer to C<@().slice>, you can
+get each individual sublist as a C<Parcel> object.
As with any multidimensional list, each sublist can be lazy separately.
=back
@@ -3651,9 +3649,9 @@
match is also available:
if $text ~~ mm:g/ (\S+:) <rocks> / {
- say "Matched { +@@() } times"; # Note: forced eager here
+ say "Matched { +@().slice } times"; # Note: forced eager here by +
- for @@() -> $m {
+ for @().slice -> $m {
say "Match between $m.from() and $m.to()";
say 'Right on, dude!' if $m[0] eq 'Perl';
say "Rocks like $m<rocks>";
Modified: docs/Perl6/Spec/S07-iterators.pod
===================================================================
--- docs/Perl6/Spec/S07-iterators.pod 2010-02-02 18:15:55 UTC (rev 29619)
+++ docs/Perl6/Spec/S07-iterators.pod 2010-02-02 18:20:08 UTC (rev 29620)
@@ -231,6 +231,21 @@
to facilitate numeric end testing if that is desired. If C<$max> is
not supplied, the iterator may choose a suitable batch size.
+=head2 method flat {...}
+
+This returns an iterator that always flattens by calling C<.get> internally
+(which discards any parcel structure, returning only the parcel's elements).
+The returned iterator will always return the same value regardless of
+whether you call C<.get> or C<.getobj>.
+
+=head2 method slice {...}
+
+This returns an iterator that always anti-flattens by calling C<.getobj>
internally,
+then hiding any resulting parcel by turning it into a C<Seq> before returning
it externally.
+A list of C<Parcel> is thereby transformed into a list of C<Seq>.
+The returned iterator will always return the same value regardless of
+whether you call C<.get> or C<.getobj>.
+
=head1 The List::PushBack Role
This role defines an iterator that knows how to receive values back to