Author: larry
Date: Wed Apr  5 10:19:49 2006
New Revision: 8561

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

Log:
Clarified identity and trivial properties for too-short reduce ops.


Modified: doc/trunk/design/syn/S03.pod
==============================================================================
--- doc/trunk/design/syn/S03.pod        (original)
+++ doc/trunk/design/syn/S03.pod        Wed Apr  5 10:19:49 2006
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall <[EMAIL PROTECTED]>
   Date: 8 Mar 2004
-  Last Modified: 1 Apr 2006
+  Last Modified: 5 Apr 2006
   Number: 3
-  Version: 14
+  Version: 15
 
 =head1 Operator renaming
 
@@ -198,7 +198,7 @@
 
 =head1 Reduction operators
 
-The other metaoperator in Perl 6 is the reduction operator.  Any binary
+The other metaoperator in Perl 6 is the reduction operator.  Any infix
 operator can be surrounded by square brackets in term position to create
 a list operator that reduces using that operation:
 
@@ -216,13 +216,24 @@
 
     [<] 1, 3, 5;      # 1 < 3 < 5
 
-If no arguments are given, the operator calls C<fail> (returning
-C<undef>, or throwing an exception if C<use fatal> is in effect).  If
-exactly one argument is given, it is returned by default.  However, this
-default doesn't make sense for an operator like C<< < >> that doesn't
-return the same type as it takes, so these kinds of operators overload
-the single-argument case to return something more meaningful.  All the
-comparison operators return truth in this case.
+If no arguments are given, and if the infix operator defines
+an "identity" value property, that identity value is returned.
+(For instance, C<[*] @list> must return C<1> when C<@list> is empty.)
+In the absence of an identity value, the reduce metaoperator calls
+C<fail> (either returning C<undef>, or throwing an exception if C<use
+fatal> is in effect).
+
+If exactly one argument is given, it is returned by default.  However,
+this default doesn't make sense for an operator like C<< < >> that
+doesn't return the same type as it takes, so these kinds of operators
+overload the single-argument case to return something more meaningful.
+All the comparison operators return truth in this case.  This behavior
+is triggered by storage of the "trivial" value property on the infix
+operator.  (The trivial property is also returned for 0 arguments.)
+
+The identity and trivial properties are stored on the most general
+default variant of the infix operator, if there is more than
+one variant.  (Perhaps they can be returned simply by calling C<< infix:<op>() 
>> and C<< infix:<op>($x) >>, respectively, letting the defaults handle it.)
 
 This metaoperator can also be used on the semicolon second-dimension
 separator:

Reply via email to