Are things not working as described by that documentation?
Having read that documentation, I don't believe I saw anything inconsistent with it. I also really don't see what I'm getting here that I can't have in any language with basic collection types, and this is the only language I've ever run across that really wants me to buy new keycaps, which seems like a rather bold UI design choice.
No need for new keycaps :)
The ability to perform native operations on collections is really nice, I agree. But Perl 6 isn't the only language that has it, either. From what I've seen today, it looks like Haskell without the rigor. Maybe that makes it easier to approach, but Perl 5 has long since taught me to mistrust such appealing shortcuts for the long-term cost they impose.
Also all of the Set/Bag/Mix ASCII equivalents are fairly easy to remember or to guess once you know that they all have parens around them. ( as in guess how to spell it, and guess what it does )
(elem) left value is an element of the right value
(cont) left value contains the right value ( dual of previous )
(|) returns a superset of both sides ( or )
(&) returns a set of values that are on both sides ( and )
(-) set that contains the values that are on the left but not the right ( minus )
(^) set that contains the values that are only on one side ( xor )
(<=) left value is a subset or equal to right value ( less than or equal to )
(<) left value is only a subset of right value ( less than )
(>=) (>) duals of previous two
(.) multiset multiplication ( looks a bit like the Unicode version )
(+) Bag/Mix addition
(<+) left value has fewer or equal numbers than right value ( Bag less than or equal )
(>+) left value has more or equal numbers than right value ( Bag greater than or equal )
< a B > (<+) <a B B c> # True
< a B B > (<+) <a B B c> # True
< a B B B > (<+) <a B B c> # False
< a d > (<+) <a B B c> # False
The ones with + all can be thought of as counting variations of the or equal operators.The only one I would really complain about is the multiplication one, and there is nothing stopping someone from doing this:
my &infix:< (*) > := &infix:< (.) >;
If you really don't like them, don't use them.
I mean they are mostly wrappers around other functionality anyway https://github.com/rakudo/rakudo/blob/nom/src/core/set_opera... proto sub infix:<(elem)>($, $ --> Bool) is pure {*}
multi sub infix:<(elem)>($a, Any $b --> Bool) {
$a (elem) $b.Set(:view);
}
multi sub infix:<(elem)>($a, Set $b --> Bool) {
$b.EXISTS-KEY($a); # internal method for implementing $b{ $a } :exists
}I think you are mistaking `<a b c d>` with a `Set`. `< >` is a shorthand for "give me a `List` of these words" (or in this case, characters). `<a b c d>.Set` would coerce you a `Set` from that list. The set operators coerce by default, so you can pass it a list of words without requiring you to coerce it yourself beforehand.
The OP had some snark to offer on the subject of "Texas" operators, and the documentation lists them by their Unicode glyphs. That they work I get. But I think it's reasonable to gather a sense of second-class citizenship from their presentation.
my $set-of-sets = set $set;
The above will create a new set with $set as its only member.
> Set types always have True as values, and since we don’t care about iterating over Pair objects in our loop, we use the keys [function] to get just the keys of the set: the email addresses.
The impression I took away from that was that you needed to make sure to pass keys(@set) rather than just @set in the operator, or else you'd get weirdness in the result. Having just installed Rakudo and fired up a REPL to find out for myself what'd happen, I find:
- that my understanding from the post was erroneous
- that there's some kind of weird set/string coercion going on that isn't replicable in the terms the REPL uses to describe it
- that the given examples do not reliably generalize
- that nothing which seems to make sense actually works
- that nothing which seems to work actually makes sense
- that I'm now bleeding slightly from both caruncles.
Having not closely followed the Perl 6 development process, I am very glad to see it has taken on board the frequently uttered and extremely well justified criticism of Perl 5 that it's not consistent enough, and that there are so many syntactic and semantic special cases that no one who doesn't heavily specialize in the language can use it very reliably.