develooper Front page | perl.perl5.porters | Postings from July 2012

Re: Smartmatch two cents (was... List::Util... when...)

Thread Previous | Thread Next
Ricardo Signes
July 6, 2012 10:20
Re: Smartmatch two cents (was... List::Util... when...)
Message ID:
* Aaron Priven <> [2012-07-06T13:02:50]
> It seems reasonable to me to argue that "in" is too specific, or not
> powerful enough, to bother including in Perl, compared to more flexible
> constructs such as the any() provided by Perl6::Junction. I don't agree
> with that, because I think "is this an element of that list" is a basic
> concept that is very commonly needed, and which deserves to have an easy
> and utterly clear way to write it, and I think "$x in (list)" is a lot
> clearer than "$x eq any(list)". But it's certainly reasonable to think
> otherwise.
> But that has nothing to do with types. You wrote originally:
> > We're not going to be adding an `in` operator, because it goes against the
> > idea of where Perl decides what type to use.

It does, because in Perl 5, the question of type is often embedded in the
operator.  == forces its operands to act as numbers.  eq, as strings.

If the values held the types, `in` would be straightforward.  In Perl 5, the
operators hold the types, so `in` would have to pick a type of its own.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About