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

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

Thread Previous | Thread Next
Reverend Chip
July 4, 2012 13:36
Re: Smartmatch two cents (was... List::Util... when...)
Message ID:
On 7/3/2012 11:02 AM, Jesse Luehrs wrote:
> On Tue, Jul 03, 2012 at 01:58:45PM -0400, Eric Brine wrote:
>> On Tue, Jul 3, 2012 at 4:59 AM, Ed Avis <> wrote:
>>> As in Python, 'in' could work for both arrays and hashes:
>>>    $x in @array
>>>    $x in %hash    # same as exists $hash{$x}
>> So C<< $x in @array >> checks the values, and C<< $x in %hash >> checks the
>> keys? Isn't that confusing?
> This sort of thing is why I never liked the smartmatch behavior for
> arrays and hashes either. It picks one arbitrary interpretation, and
> blesses it with special syntax. Being explicit about what you mean (via
> something like Smart::Match or Perl6::Junction) is a much much better
> idea.

In fairness, that description matches *all* language design, especially

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