Skip to content

Commit

Permalink
[S02] be more explicit about iterating sets/bags
Browse files Browse the repository at this point in the history
The intent has always been that when you use a set or bag as a list,
it behaves as a list of its keys, regardless of any underlying hash
interface it might also respond to.  You must use .pairs explicitly
to get the hash pairs out of a set or bag as a list.
  • Loading branch information
TimToady committed Oct 26, 2010
1 parent 00572dd commit 32511f7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions S02-bits.pod
Expand Up @@ -13,8 +13,8 @@ Synopsis 2: Bits and Pieces

Created: 10 Aug 2004

Last Modified: 16 Sep 2010
Version: 225
Last Modified: 25 Oct 2010
Version: 226

This document summarizes Apocalypse 2, which covers small-scale
lexical items and typological issues. (These Synopses also contain
Expand Down Expand Up @@ -1376,8 +1376,8 @@ These types do (at least) the following roles:
Block Callable
Seq Iterable
Range Iterable
Set Associative[Bool]
Bag Associative[UInt]
Set Associative[Bool] Iterable
Bag Associative[UInt] Iterable
Enum Associative
EnumMap Associative Positional Iterable
Signature
Expand Down Expand Up @@ -1407,6 +1407,9 @@ simultaneously, but an iterator/list itself has only one thread of
consumption. Every time you do C<get> on an iterator, a value
disappears from its list.

Note that C<Set> and C<Bag> iterators return only keys, not values. You
must explicitly use c<.pairs> to get key/value pairs.

=head2 Mutable types

Objects with these types have distinct C<.WHICH> values that do not change
Expand Down

0 comments on commit 32511f7

Please sign in to comment.