Author: lwall
Date: 2010-06-02 18:51:06 +0200 (Wed, 02 Jun 2010)
New Revision: 31050
Modified:
docs/Perl6/Spec/S03-operators.pod
Log:
[S03] refine hyper dwimminess to be more like APL, with modular semantics
Modified: docs/Perl6/Spec/S03-operators.pod
===================================================================
--- docs/Perl6/Spec/S03-operators.pod 2010-06-02 16:01:46 UTC (rev 31049)
+++ docs/Perl6/Spec/S03-operators.pod 2010-06-02 16:51:06 UTC (rev 31050)
@@ -15,8 +15,8 @@
Created: 8 Mar 2004
- Last Modified: 26 May 2010
- Version: 206
+ Last Modified: 2 Jun 2010
+ Version: 207
=head1 Overview
@@ -4014,11 +4014,11 @@
[Note: if you are worried about Perl getting confused by something like this:
- foo «*»
+ func «*»
then you shouldn't worry about it, because unlike previous versions,
Perl 6 never guesses whether the next thing is a term or operator.
-In this case it is always expecting a term unless C<foo> is predeclared
+In this case it is always expecting a term unless C<func> is predeclared
to be a type or value name.]
The upgrade never happens on the "blunt" end of a hyper. If you write
@@ -4031,11 +4031,35 @@
$foo »*« $bar
you are requiring the shapes to be identical, or an exception will be thrown.
-By default this dwimmery only upgrades whole dimensions, not short lists.
-However, any list ending with C<*> can also be arbitrarily extended as if
-the last element of the list were arbitrarily replicated C<*> times. But
-this happens only on the "dwimmy" side.
+For all hyper dwimminess, if a scalar is found where the other side expects a
list,
+the scalar is considered to be a list of one element repeated C<*> times.
+
+Once we have two lists to process, we have to decide how to put the elements
+into correspondence. If both sides are dwimmy, the short list will have be
repeated
+as many times as necessary to make the appropriate number of elements.
+
+If only one side is dwimmy, then the list on that side only will be grown or
+truncated to fit the list on the non-dwimmy side.
+
+ (1,2,3,4) »+« (1,2) # always error
+ (1,2,3,4) «+» (1,2) # 2,4,4,6 rhs dwims to ((1,2) xx *).batch(4)
+ (1,2,3) «+» (1,2) # 2,4,4 rhs dwims to ((1,2) xx *).batch(3)
+ (1,2,3,4) «+« (1,2) # 2,4 lhs dwims to (1,2,3,4).batch(2)
+ (1,2,3,4) »+» (1,2) # 2,4,4,6 rhs dwims to ((1,2) xx *).batch(4)
+ (1,2,3) »+» (1,2) # 2,4,4,6 rhs dwims to ((1,2) xx *).batch(3)
+ (1,2,3) »+» 1 # 2,4,4,6 rhs dwims to (1 xx *).batch(3)
+
+Another way to look at it is that the dwimmy list's elements are
+indexed modulo its number of elements so as to produce as many or as
+few elements as necessary.
+
+Note that each element of a dwimmy list may in turn be expanded into
+another dimension if necessary, so you can, for instance, add one to
+all the elements of a matrix regardless of its dimensionality:
+
+ @fancy »+=» 1
+
On the non-dwimmy side, any scalar value that does not know how to
do C<Iterable> will be treated as a list of one element, and for infix
operators must be matched by an equivalent one-element list on the