Author: lwall
Date: 2009-12-03 20:00:40 +0100 (Thu, 03 Dec 2009)
New Revision: 29250

Modified:
   docs/Perl6/Spec/S02-bits.pod
   docs/Perl6/Spec/S12-objects.pod
   docs/Perl6/Spec/S32-setting-library/Containers.pod
Log:
make pair values sequences both associative and positional
revise enum mixins to distinguish attribute vs method mixin


Modified: docs/Perl6/Spec/S02-bits.pod
===================================================================
--- docs/Perl6/Spec/S02-bits.pod        2009-12-03 15:33:14 UTC (rev 29249)
+++ docs/Perl6/Spec/S02-bits.pod        2009-12-03 19:00:40 UTC (rev 29250)
@@ -13,8 +13,8 @@
 
     Created: 10 Aug 2004
 
-    Last Modified: 23 Nov 2009
-    Version: 192
+    Last Modified: 3 Dec 2009
+    Version: 193
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -1151,7 +1151,7 @@
     Set         Unordered collection of values that allows no duplicates
     Bag         Unordered collection of values that allows duplicates
     PairVal     An immutable Pair
-    PairValSet  Set of PairVals with no duplicate keys
+    PairValSeq  Seq of PairVals with no duplicate keys
     Signature   Function parameters (left-hand side of a binding)
     Parcel      List of syntactic objects
     Capture     Function call arguments (right-hand side of a binding)
@@ -1206,7 +1206,7 @@
     Set         Associative[Bool]
     Bag         Associative[UInt]
     PairVal     Associative
-    PairValSet  Associative
+    PairValSeq  Associative Postional Iterable
     Signature   
     Parcel      Positional
     Capture     Positional Associative
@@ -1227,7 +1227,7 @@
     KeySet      KeyHash of Bool (does Set in list/array context)
     KeyBag      KeyHash of UInt (does Bag in list/array context)
     Pair        A single key-to-value association
-    PairSet     A Set of Pairs
+    PairSeq     A Seq of Pairs
     Buf         Perl buffer (a stringish array of memory locations)
     IO          Perl filehandle
     Routine     Base class for all wrappable executable objects
@@ -1275,7 +1275,7 @@
 replicated the number of times specified by its corresponding value.
 (Use C<.kv> or C<.pairs> to suppress this behavior in list context.)
 
-As with C<Hash> types, C<Pair> and C<PairSet> are mutable in their
+As with C<Hash> types, C<Pair> and C<PairSeq> are mutable in their
 values but not in their keys.  (A key can be a reference to a mutable
 object, but cannot change its C<.WHICH> identity.  In contrast,
 the value may be rebound to a different object, just as a hash
@@ -1288,8 +1288,9 @@
     Hash        Associative
     KeySet      KeyHash[Bool]
     KeyBag      KeyHash[UInt]
+    KeyHash     Associative
     Pair        Associative
-    PairSet     Associative
+    PairSeq     Associative Postional Iterable
     Buf         Stringy
     IO          
     Routine     Callable

Modified: docs/Perl6/Spec/S12-objects.pod
===================================================================
--- docs/Perl6/Spec/S12-objects.pod     2009-12-03 15:33:14 UTC (rev 29249)
+++ docs/Perl6/Spec/S12-objects.pod     2009-12-03 19:00:40 UTC (rev 29250)
@@ -13,8 +13,8 @@
 
     Created: 27 Oct 2004
 
-    Last Modified: 28 Nov 2009
-    Version: 93
+    Last Modified: 3 Dec 2009
+    Version: 94
 
 =head1 Overview
 
@@ -1713,7 +1713,7 @@
     3 ~~ Day    # True, using Day as a subset of Int
     Day.mapping # hash of key/value pairs
 
-The C<.mapping> method returns a C<PairValSet> that may be used like
+The C<.mapping> method returns a C<PairValSeq> that may be used like
 a constant hash value:
 
     my enum CoinFace <Heads Tails>;
@@ -1747,7 +1747,9 @@
     %e<ook.> = 1;
     %e<ook?> = 2;
 
-The enum installer inspects list values for pairs, where the value
+The return value of an anonymous enum is a c<PairValSeq>.
+
+The enum composer inspects list values for pairs, where the value
 of the pair sets the next value explicitly.  Non-pairs C<++> the
 previous value.  (Str and buf types increment like Perl 5 strings.)
 Since the C<«...»> quoter automatically recognizes
@@ -1782,7 +1784,7 @@
 or the old one.)  Any explicit sub or type definition hides all imported
 enum values of the same name but will produce a warning unless
 C<is redefined> is included.  Note that true() is a built-in function
-and requires an argument, while True is short for C<Bool::True> and
+and requires an argument, while C<True> is short for C<Bool::True> and
 does not take an argument.
 
 Since non-native enum values know their enum type, they may be used to
@@ -1801,16 +1803,31 @@
 An enum type is not in itself a role type; however, the C<but>
 and C<does> operators know that when a user supplies an enum type,
 it implies the generation of an anonymous mixin role that creates an
-attribute of the enum type along with an accessor.  If we assume
-there is a C<Has> role that creates an attribute, then
+an appropriate accessor, read-write if an attribute is being created, and
+read-only otherwise.  It depends on whether you mix in the whole
+or a specific enum value or the whole enum type:
 
+    $x = "Today" but Tue;       # $x.Day is read-only
+    $x = "Today" but Day;       # $x.Day is read-write
+
+Mixing in a specific enum object implies only the readonly accessor.
+
     $x = "Today" but Tue;
 
-really means something more like:
+really means something like:
 
-    $x = "Today";
-    $x does Has[Day, '$.Day', (:rw), { Tue }];
+    $x = "Today".clone;
+    $x does anon role { method Day { Day::Tue } };
 
+The fully qualified form does the same thing, and is useful
+in case of enum collision:
+
+    $x = "Today" but Day::Tue;
+
+Note that the method name is still C<.Day>, however.  If
+you wish to mix in colliding method names, you'll have to
+mixin your own anonymous role with different method names.
+
 Since enum supplies the type name as a coercion, you can
 also say:
 
@@ -1839,6 +1856,21 @@
 
 all return false.
 
+Mixing in the whole enum type produces a read-write attribute:
+
+    $x = "Today" but Day;       # read-write .Day
+
+really means something like:
+
+    $x = "Today".clone;
+    $x does anon role { has Day $.Day is rw }
+
+Note that the attribute is not initialized.  If that is desired
+you can supply a C<WHENCE> closure:
+
+    $x = "Today" but Day{ :Day(Tue) }
+    $x = "Today" but Day{ Tue }  # conjecturally, for "simple" roles
+
 To add traits to an enum declaration, place them after the declared
 name but before the list:
 
@@ -1876,7 +1908,7 @@
     $obj.Bool.Int != 0
 
 Never compare a value to "C<true>", or even "C<True>".  Just use it
-in a boolean context.
+in a boolean context.  Well, almost never...
 
 If you wish to be explicit about a boolean context, use the high-level
 C<true> function or C<?> prefix operator, which are underlying based

Modified: docs/Perl6/Spec/S32-setting-library/Containers.pod
===================================================================
--- docs/Perl6/Spec/S32-setting-library/Containers.pod  2009-12-03 15:33:14 UTC 
(rev 29249)
+++ docs/Perl6/Spec/S32-setting-library/Containers.pod  2009-12-03 19:00:40 UTC 
(rev 29250)
@@ -19,8 +19,8 @@
 
     Created: 19 Feb 2009 extracted from S29-functions.pod
 
-    Last Modified: 29 Sep 2009
-    Version: 9
+    Last Modified: 3 Dec 2009
+    Version: 10
 
 The document is a draft.
 
@@ -810,19 +810,22 @@
 
 =back
 
-=head2 PairValSet
+=head2 PairValSeq
 
-    class PairValSet does Associative {...}
+    class PairValSeq does Associative does Positional {...}
 
-An immutable hash value, essentially.  The keys may
-not contain duplicates, while the values may.
+An immutable hash value, viewable either as a (readonly) hash or
+as a sequence of C<PairVal>s.  The keys may not contain duplicates,
+while the values may.
 
-=head2 PairSet
+=head2 PairSeq
 
-    class PairSet does Associative {...}
+    class PairSeq does Associative does Positional {...}
 
-A hash value that is mutable only in values.  The keys may
-not contain duplicates, while the values may.
+A hash value that is mutable only in values, differing from a normal
+hash insofar as the key set is frozen.  It may be accessed either as
+a frozen hash or as a sequence of C<Pair>s. The keys may not contain
+duplicates, while the values may.
 
 =head2 Set
 

Reply via email to