Permalink
Browse files

say how to turn pairs/hashes into sets/bags

  • Loading branch information...
1 parent 0380487 commit 1e7aec467b4eb83738513f0bcb6d6ff07e89ec95 @TimToady TimToady committed May 14, 2013
Showing with 5 additions and 0 deletions.
  1. +5 −0 S32-setting-library/Containers.pod
View
5 S32-setting-library/Containers.pod
@@ -1122,6 +1122,9 @@ simply take the list of objects slurped in and turn them into a set.
Together these rules allow us to constructs sets and bags containing
sets and bags as elements.
+(To create a set from a list of Pairs or a hash, use a C<Set()> coercion
+rather than a constructor.)
+
=over
=item pick
@@ -1167,6 +1170,8 @@ replication values.
Sets and bags do not flatten into list context, nor do the constructors
interpolate items passed to them, even if they look like sets or bags.
+(To create a bag from a list of Pairs or a hash, use a C<Bag()> coercion
+rather than a constructor.)
=over

1 comment on commit 1e7aec4

@colomon
Perl 6 member

There is one thorny detail here. Before one could say

bag { foo => 10000000000, bar => 17, baz => 42 }

From a user's perspective, there isn't much practical difference between that and

{ foo => 10000000000, bar => 17, baz => 42 }.Bag

But from an implementor's perspective, how is one supposed to efficiently construct that Bag? A secret constructor that takes a list of Pairs?

Please sign in to comment.