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

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

Thread Previous | Thread Next
From:
Ricardo Signes
Date:
July 6, 2012 05:14
Subject:
Re: Smartmatch two cents (was... List::Util... when...)
Message ID:
20120706121359.GB22115@cancer.codesimply.com
* Aaron Priven <aaron@priven.com> [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
values.

-- 
rjbs

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About