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

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

Thread Previous | Thread Next
Ricardo Signes
August 17, 2012 17:42
Re: fixing smartmatch just hard enough (and when, too)
Message ID:
* Abigail <> [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.


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