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

Re: fixing smartmatch just hard enough (and when, too)

Thread Previous | Thread Next
From:
Ricardo Signes
Date:
August 17, 2012 17:42
Subject:
Re: fixing smartmatch just hard enough (and when, too)
Message ID:
20120818004235.GA686@cancer.codesimply.com
* Abigail <abigail@abigail.be> [2012-08-17T09:24:10]
> For me, one of the few advantages I saw in using ~~ is not having to 
> wonder when to use == vs eq vs =~. The above table suggests that
> 
>     "0.0" ~~ 0
> 
> is false, while it's currently true. That bothers me. IMO, a "smart match" 
> should be able to say, "hmmm, both my operands look like numbers, you know
> what, I'll use '==' to compare them!"
> 
> Would this be workable:
> 
>       $a      $b                  Meaning
>       ======= =======             ======================
>       [...]
>       Any     Looks like number   $a == $b (without a "isn't numeric" warning)
>       Any     Simple              $a eq $b
>       Any     Any                 fatal
>       [...]

This is similar to something Damian suggested, which was == if both $a *and* $b
look_like_number.  I think that's less jarring to me, as I think I'd expect
("foo" ~~ "0e0") to fail.

What do you think?

At any rate, I'm not writing off the suggestion, and am going to sleep on it...
fewer than 380 times.

-- 
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