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

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

Thread Previous | Thread Next
From:
Jesse Luehrs
Date:
July 3, 2012 11:03
Subject:
Re: Smartmatch two cents (was... List::Util... when...)
Message ID:
20120703180258.GN30375@tozt.net
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.

-doy

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