
Set in Your Ways: Perl 6’s Setty and Baggy Types - kumaranvpl
https://perl6advent.wordpress.com/2016/12/07/set-in-your-ways-perl-6s-setty-and-baggy-types/
======
jlarocco
Every Perl6 article I read makes it even less likely that I'll ever use it.

It's so ugly, with so many arcane things to remember, with so many weird
naming conventions that just don't make any sense to me.

> We intersected two sets with the ∩, U+2229 INTERSECTION, intersection
> operator and received a set that contains only the elements present in both
> original sets.

I'm not against having built-in Unicode operators, but the non-Unicode version
should be the name of the character. What's the non-Unicode version of "∩"?
Obviously it's "(&)"! Good thing there are only 57 of them to remember!

I tried to enter "∩" just now in Emacs: (ctrl-x, 8, enter, i, n, t, tab, r,
tab, s, e, c, tab). It would have been shorter to just type "intersection"...
And why is that called the "Texas" version?

~~~
cygx
_What 's the non-Unicode version of "∩"? Obviously it's "(&)"!_

I find that pretty obvious, actually. After all

    
    
        A ∩ B = { x ∈ A & x ∈ B }

~~~
jlarocco
That at least explains where it comes from, but I'd still argue it won't be
obvious to people at first.

And it's still kind of confusing. If the goal is to match math notation then
wouldn't (^) or (+) make more sense?

    
    
        A ∩ B = { x ∈ A ∧ x ∈ B }

~~~
cygx
_If the goal is to match math notation then wouldn 't (^) or (+) make more
sense?_

Not necessarily. & is the ASCII symbol associated with logical 'and' that most
programming languages have settled on, including Perl6, so for internal
consistency, it makes sense to use it. Also note that the ampersand, while
pretty rare, is sometimes used for that purpose in mahematical notation
([https://en.wikipedia.org/wiki/List_of_logic_symbols](https://en.wikipedia.org/wiki/List_of_logic_symbols)).

------
zokier

        say 42 ∈ <42  55  1>;   # False; ∈ operator cares about object identity
    

As an outsider, this seems like a huge gotcha. I suppose the weirdest thing
(after reading some docs) is why < > quotation is used as a set literal here.
Would something like

    
    
        say 42 ∈ (42, 55, 1);
    

work as expected? Or what would be the canonical way of writing an Int (not
IntStr) set literal?

~~~
sp332
The angle brackets are explicitly string operators. So the set contains the
string "42" but not the number 42. Perl does generally have different
operators for strings vs numbers, so that's something you'd be used to
thinking about already. Probably not a huge gotcha.

Edit: these things are weird though.
[https://docs.perl6.org/type/IntStr](https://docs.perl6.org/type/IntStr)

------
bshimmin
I stared at

    
    
      .put for @wanted.combinations.grep: { $materials ≽ [⊎] |$^stuff-we-want };
    

and the preceding lines for some time, and then read the description, clicked
through a few of the links on the different operators and read the
explanations of those, and then I finally understood what was happening here.
I worry, though, that at this point in my life I would either 1) never be able
to remember all this stuff; 2) even if I could remember it, never be in a
position where it would dawn on me that whatever I was trying to do was a good
fit for it.

~~~
smitherfield
Yeah, as someone whose go to languages are C++, Scala and Ruby[1], it's
awesome that Perl 6 does so much[2], but I think I'd have a hard time keeping
track of it all.

[1] Meaning I like having lots of features in my toolbox.

[2] And, amazingly, Rakudo is a pretty compact executable compared to most
other langs.

------
throwaway7645
I really like all the built-in functionality. As long as the doc is good I can
live with the complexity.

~~~
throwanem
Consistency of inconsistency would be nice. For example, I don't see why Set
"values" should ever be exposed anywhere, since the semantics of the
collection type don't include them. Seems like a great big gotcha waiting to
happen.

~~~
gpvos
_In general, [Perl operators] do what you want, unless you want consistency._
— man perlfunc (of Perl5)

~~~
throwanem
I thought I remembered hearing part of the idea with Perl 6 was that there'd
be _less_ of that. Apparently I have mistaken a forlorn hope for a vague
memory.

------
andrewpk
those hyper operators...

------
dscpls
One of the best punny titles I've ever heard. Well done. Really well done.

