Author: lwall
Date: 2009-08-06 15:14:15 +0200 (Thu, 06 Aug 2009)
New Revision: 27882
Modified:
docs/Perl6/Spec/S02-bits.pod
Log:
[S02] Note that coercion to Nil provides "loop else" functionality
Define what we mean by the Parcel type.
Modified: docs/Perl6/Spec/S02-bits.pod
===================================================================
--- docs/Perl6/Spec/S02-bits.pod 2009-08-06 05:34:41 UTC (rev 27881)
+++ docs/Perl6/Spec/S02-bits.pod 2009-08-06 13:14:15 UTC (rev 27882)
@@ -13,8 +13,8 @@
Created: 10 Aug 2004
- Last Modified: 17 Jun 2009
- Version: 171
+ Last Modified: 6 Aug 2009
+ Version: 172
This document summarizes Apocalypse 2, which covers small-scale
lexical items and typological issues. (These Synopses also contain
@@ -980,9 +980,25 @@
as a null list into list context, and an empty capture into slice
context. A C<Nil> object may also carry failure information,
but if so, the object behaves as a failure only in item context.
-Use C<Failure>/C<undef> when you want to return a hard failure that
-will not evaporate in list context.
+Use C<Failure> when you want to return a hard failure that
+will not evaporate in list context. Casting to C<Nil> is one
+way of evaluating an expression and throwing the result away:
+ @inclist = map { $_ + 1 }, @list || Nil( warn 'Empty @list!' );
+
+ @inclist = do for @list || Nil( warn 'Empty @list!' ) {
+ $_ + 1;
+ }
+
+Or if you want to test the how many results you got back from
+the C<map> or C<for>:
+
+ @inclist = map { $_ + 1 }, @list or Nil( warn 'Empty @list!' );
+
+ @inclist = do for @list {
+ $_ + 1;
+ } or Nil( warn 'Empty @list!' )
+
=head2 Immutable types
Objects with these types behave like values, i.e. C<$x === $y> is true
@@ -1399,7 +1415,7 @@
C<@x> may be bound to an object of the C<Array> class, but it may also
be bound to any object that does the C<Positional> role, such as a
-C<List>, C<Seq>, C<Range>, C<Buf>, or C<Capture>. The C<Positional>
+C<List>, C<Seq>, C<Range>, C<Buf>, C<Parcel>, or C<Capture>. The C<Positional>
role implies the ability to support C<< postcircumfix:<[ ]> >>.
Likewise, C<%x> may be bound to any object that does the C<Associative>
@@ -1571,6 +1587,27 @@
=item *
+A list of one or more objects may be grouped together by parentheses
+into a "parenthesis cell", or C<Parcel>. This kind of list should
+not be confused with the flattening list context. Instead, this is
+a raw syntactic list; no interpretation is made of the list without
+knowing what context it will be evaluated in. For example, when
+you say:
+
+ (1,2,3,:mice<blind>)
+
+the result is a C<Parcel> object containing three C<Int> objects
+and a C<Pair> object, that is, four positional objects. When, however,
+you say something like:
+
+ rhyme(1,2,3,:mice<blind>)
+
+the C<Parcel> is translated (at compile time, in this case)
+into a C<Capture> with 3 positionals and one named argument
+in preparation for binding.
+
+=item *
+
An argument list may be captured into an object with backslashed parens:
$args = \(1,2,3,:mice<blind>)