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

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

Thread Previous | Thread Next
From:
Reverend Chip
Date:
July 4, 2012 13:36
Subject:
Re: Smartmatch two cents (was... List::Util... when...)
Message ID:
4FF4A936.3010805@gmail.com
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 <eda@waniasset.com> 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
Perl's.


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