Dave Whipp wrote:
> Carl Mäsak wrote:
>> Paul (>):
>>> I can't find anything in the existing synopses about Blobs.
>>> Probably looking in the wrong place, sorry.
> Re-reading that, a slightly tangent (though still on topic, I hope)
> thought come to mind. The definition of the Mapping immutable type:
> Mapping Set of Pairs with no duplicate keys
> The question is, what to do when a Mapping is created from a
> source that contains pairs with duplicate keys? The Perl5 answer is
> simply to silently drop all but the last in the list ... but I can think
> of many other answers: sometimes you might want an error; other times
> you might want to create a list/set/bag from the values of the duplicate
> keys; other times a junction might be appropriate. One theme of P6 is to
> not lose information unnecessarily -- which is what P5 does here.
It would be nice indeed if there were a simple syntax for specifying
that. OTOH it's not hard to do it manually in two lines or so.
> The option of creating a list of the values is interesting because, in
> scalar context, a list returns the value of its last item
That's Perl 5 semantics, not Perl 6.
In Perl 6 a List in scalar context becomes a List or Array object:
$ ./perl6 -e 'my $x = 1, 2, 3; say $x.perl'
[1, 2, 3]
> -- which is
> the existing P5 semantics but without losing information until the value
> is used as a scalar. And lists can be used to construct all the other
> interesting cases.
> Will there be a syntax for choosing the strategy for reducing a list of
> pairs that contains duplicate keys to a "Mapping"?