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 05:14
Re: Smartmatch two cents (was... List::Util... when...)
Message ID:
* Aaron Priven <> [2012-07-06T02:15:24]
> sub in {
>    my $member = shift; 
>    for (@_) {
>       return 1 if $member eq $_;
>    }
>    return q{};
> }
> Except for the use of "eq", it doesn't assume anything about the type of
> anything. And inferring numeric / string from the operator is what, I
> thought, Perl did. Hence the suggestion of a numeric "in" operator.
> That's not to say it's necessarily worth doing. Maybe, as Aaron Crane
> suggests, it's not "powerful enough to justify its own existence." 

The use of "eq" is the primary type issue.  If we need a numeric in, then now
we're talking about *two* operators to justify, each with one very specific
use.  On the other hand, you can use any() with all sorts of comparitors and


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