Author: larry
Date: Tue Nov 28 17:27:59 2006
New Revision: 13483
Modified:
doc/trunk/design/syn/S06.pod
Log:
Distinguished Set and Bag values from KeySet and KeyBag containers.
Modified: doc/trunk/design/syn/S06.pod
==
--- doc/trunk/design/syn/S06.pod(original)
+++ doc/trunk/design/syn/S06.podTue Nov 28 17:27:59 2006
@@ -13,9 +13,9 @@
Maintainer: Larry Wall [EMAIL PROTECTED]
Date: 21 Mar 2003
- Last Modified: 31 Oct 2006
+ Last Modified: 28 Nov 2006
Number: 6
- Version: 60
+ Version: 62
This document summarizes Apocalypse 6, which covers subroutines and the
@@ -1365,8 +1365,9 @@
Block Executable objects that have lexical scopes
ListLazy Perl list (composed of Seq and Range parts)
Seq Completely evaluated (hence immutable) sequence
-Range Incrementally generated (hence lazy) sequence
-Set Unordered Seqs that allow no duplicates
+Range A pair of Ordered endpoints; gens lazy Seq in list context
+Set Unordered Seq that allows no duplicates
+Bag Unordered Seq that allows duplicates
JunctionSets with additional behaviours
PairSeq of two elements that serves as a one-element Mapping
Mapping Pairs with no duplicate keys
@@ -1379,9 +1380,12 @@
Objects with these types have distinct C.WHICH values that do not change
even if the object's contents change.
+Scalar Perl scalar
Array Perl array
HashPerl hash
-Scalar Perl scalar
+KeyHash Perl hash that autodeletes values matching default
+KeySet KeyHash of Bool (does Set in list/array context)
+KeyBag KeyHash of UInt (does Bag in list/array context)
Buf Perl buffer (a stringish array of memory locations)
IO Perl filehandle
Routine Base class for all wrappable executable objects
@@ -1398,6 +1402,38 @@
Object Perl 6 object
Grammar Perl 6 pattern matching namespace
+A CKeyHash differs from a normal CHash in how it handles default
+values. If the value of a CKeyHash element is set to the default
+value for the CKeyHash, the element is deleted. If undeclared,
+the default default for a CKeyHash is 0 for numeric types, CFalse
+for boolean types, and the null string for string and buffer types.
+A CKeyHash of a CObject type defaults to the undefined prototype
+for that type. More generally, the default default is whatever defined
+value an Cundef would convert to for that value type. A CKeyHash
+of CScalar deletes elements that go to either 0 or the null string.
+A CKeyHash also autodeletes keys for normal undef values (that is,
+those undefined values that do not contain an unthrown expections).
+
+A CKeySet is a CKeyHash of booleans with a default of CFalse.
+If you you use the CHash interface and increment an element of a
+CKeySet its value becomes true (creating the element if it doesn't
+exist already). If you decrement the element it becomes false and
+is automatically deleted. When not used as a CHash (that is,
+when used as an CArray or list or CSet object) a CKeySet
+behaves as a CSet of its keys. (Since the only possible value of
+a CKeySet is the CTrue value, it need not be represented in
+the actual implementation with any bits at all.)
+
+A CKeyBag is a CKeyHash of CUInt with default of 0. If you
+you use the CHash interface and increment an element of a CKeyBag
+its value is increased by one (creating the element if it doesn't exist
+already). If you decrement the element the value is decreased by one;
+if the value goes to 0 the element is automatically deleted. When not
+used as a CHash (that is, when used as an CArray or list or CBag
+object) a CKeyBag behaves as a CBag of its keys, with each key
+replicated the number of times specified by its corresponding value.
+(Use C.kv or C.pairs to suppress this behavior in list context.)
+
=head2 Value types
Explicit types are optional. Perl variables have two associated types: