$Larry has just updated the pod:
   doc/trunk/design/syn/S03.pod

=head1 Changes to existing operators
-If one argument is insufficiently dimensioned, Perl "upgrades" it:
+If either argument is insufficiently dimensioned, Perl "upgrades" it:
 
      (3,8,2,9,3,8) >>-<< 1;          # (2,7,1,8,2,7)
 
@@ -354,11 +354,26 @@
     [[1, 2], 3] »+« [4, [5, 6]]  #    [[1,2] »+« 4, 3 »+« [5, 6]]
                                  # == [[5, 6], [8, 9]]

+More generally, hyper operators work recursively for any object
+matching the C<Each> role even if the object itself doesn't support
+the operator in question:
+
+    Bag(3,8,[2,Seq(9,3]],8) >>-<< 1;         # Bag(2,7,[1,Seq(8,2)],7)
+    Bag(3,8,[2,Seq(9,3)],8) >>-<< (1,1,1,1); # Bag(2,7,[1,Seq(8,2)],7)
+    Bag(3,8,[2,Seq(9,3)],8) >>-<< (1,1,2,1); # Bag(2,7,[2,Seq(9,3)],7)

That last one puzzles me - by this info:
-If one argument is insufficiently dimensioned, Perl "upgrades" it:
+If either argument is insufficiently dimensioned, Perl "upgrades" it:
 
      (3,8,2,9,3,8) >>-<< 1;          # (2,7,1,8,2,7)

shouldn't it be (not knowing what to do w/ Bag or Seq):
   Bag(3,8,[2,Seq(9,3)],8) >>-<< (1,1,2,1); # Bag(2,7,[0,Seq(8,3)],7)

or:
   Bag(3,8,[2,Seq(9,3)],8) >>-<< (1,1,2,1); # Bag(2,7,[0,Seq(7,2)],7)

(the '2' being 'upgraded to [2,2] or [2,2,2] or [2, Seq(2,2)])


+
+In particular, tree node types with C<Each> semantics enable visitation:
+
+    $tree.».foo;                                # short for $tree.each: { 
.foo }
+
+You are not allowed to define your own hyper operators, because they
+are supposed to have consistent semantics derivable entirely from
+the modified scalar operator.  If you're looking for a mathematical
+vector product, this isn't where you'll find it.  A hyperoperator
+is one of the ways that you can promise to the optimizer that your
+code is parallelizable.  (The tree visitation above is allowed to
+have side effects, but it is erroneous for the meaning of those side
+effects to depend on the order of visitation.)

a

Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED] 
VOICE: (608) 261-5738  FAX 264-5932

"Truth is eternal, knowledge is changeable.
 It is disastrous to confuse them."
 -- Madeleine L'Engle

Reply via email to