Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[svn:perl6-synopsis] r13350 - doc/trunk/design/syn

5 views
Skip to first unread message

la...@cvs.perl.org

unread,
Oct 30, 2006, 3:18:28 PM10/30/06
to perl6-l...@perl.org
Author: larry
Date: Mon Oct 30 12:18:19 2006
New Revision: 13350

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

Log:
1st whack at applying dwimmy hypers to hashes.


Modified: doc/trunk/design/syn/S03.pod
==============================================================================
--- doc/trunk/design/syn/S03.pod (original)
+++ doc/trunk/design/syn/S03.pod Mon Oct 30 12:18:19 2006
@@ -12,9 +12,9 @@

Maintainer: Larry Wall <la...@wall.org>
Date: 8 Mar 2004
- Last Modified: 16 Oct 2006
+ Last Modified: 30 Oct 2006
Number: 3
- Version: 72
+ Version: 73

=head1 Changes to Perl 5 operators

@@ -877,6 +877,34 @@
Beyond all that, "array of scalar" types are known at compile time not to
need recursive hypers, so the operations can be vectorized aggressively.

+Hypers may be applied to hashes as well as to lists. In this case
+"dwimminess" says whether to ignore keys that do not exist
+in the other hash, while "non-dwimminess" says to use all keys that are
+in either hash. That is,
+
+ %foo «+» %bar;
+
+gives you the intersection of the keys, while
+
+ %foo »+« %bar;
+
+gives you the union of the keys. Asymmetrical hypers are also useful;
+for instance, if you say:
+
+ %outer »+» %inner;
+
+only the %inner keys that already exist in %outer will occur in the result.
+Note, however, that you want
+
+ %outer »+=« %inner;
+
+in order to pass accumulated statistics up a tree, assuming you want %outer
+to have the union of keys.
+
+Unary hash hypers and binary hypers that have only one hash operand
+will apply the hyper operator to just the values but return a new
+hash value with the same set of keys as the original hash.
+
=head2 Reduction operators

The fourth metaoperator in Perl 6 is the reduction operator. Any

Larry Wall

unread,
Oct 30, 2006, 3:34:58 PM10/30/06
to perl6-l...@perl.org
Arguably I've got the dwimminess backwards on this. It seems like

%outer «+=» %inner

ought to dwim that I want the union of keys. In that view the standard
non-dwimmy behavior is to ignore keys that are not in the other hash,
and dwimmery consists of using keys even if they aren't in the other hash.
On the other hand, it seems odd that the "big" end of a hyper would imply
fewer keys. Obviously it doesn't make much difference whether we write

%foo «+=» 1

or

%foo »+=» 1

since the key set has to be considered fixed in any event.

Well, as usual, I can argue it both ways, and will doubtless flipflop
on the issue a couple of times yet... :)

Larry

0 new messages