Skip to content
This repository
Browse code

say how to turn pairs/hashes into sets/bags

  • Loading branch information...
commit 1e7aec467b4eb83738513f0bcb6d6ff07e89ec95 1 parent 0380487
Larry Wall TimToady authored

Showing 1 changed file with 5 additions and 0 deletions. Show diff stats Hide diff stats

  1. +5 0 S32-setting-library/Containers.pod
5 S32-setting-library/Containers.pod
Source Rendered
@@ -1122,6 +1122,9 @@ simply take the list of objects slurped in and turn them into a set.
1122 1122 Together these rules allow us to constructs sets and bags containing
1123 1123 sets and bags as elements.
1124 1124
  1125 +(To create a set from a list of Pairs or a hash, use a C<Set()> coercion
  1126 +rather than a constructor.)
  1127 +
1125 1128 =over
1126 1129
1127 1130 =item pick
@@ -1167,6 +1170,8 @@ replication values.
1167 1170
1168 1171 Sets and bags do not flatten into list context, nor do the constructors
1169 1172 interpolate items passed to them, even if they look like sets or bags.
  1173 +(To create a bag from a list of Pairs or a hash, use a C<Bag()> coercion
  1174 +rather than a constructor.)
1170 1175
1171 1176 =over
1172 1177

1 comment on commit 1e7aec4

colomon
Collaborator

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.
Something went wrong with that request. Please try again.