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

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

Thread Previous | Thread Next
From:
David Golden
Date:
August 22, 2012 17:10
Subject:
Re: Re: fixing smartmatch just hard enough (and when, too)
Message ID:
CAOeq1c8sGM+NZioKbzygXvv40KBLKz=Yn3uMa26ve2np9aTPyQ@mail.gmail.com
On Wed, Aug 22, 2012 at 7:55 PM, Damian Conway <damian@conway.org> wrote:

>
> Smartmatch (~~) table
> =====================
>
>     $a       $b                    Meaning
>     =====    ===================   ========================
>
>     Any      ~~-overloaded   [1]   $b->ol_method($a, 'rev')
>     ~~-ol    Any             [1]   $a->ol_method($b)
>     Any      undef                 ! defined $a
>     Any      CodeRef, &{}-ol       $b->($a)
>     Any      Regexp, qr-ol         $a =~ $b
>     Any      unambiguous Num [2]   $a == $b
>     Any      unambiguous Str [3]   $a eq $b
>     Any      Any                   undef (with fatalizable warning)
>
>
I'm sold on the overloading precedence.  I still prefer
Any~~NonReferenceScalar to be "$a eq $b" (with fatalizable warning) and
Any~~AnythingElse can be fatal.  I think that minimizes surprise for the
most common case.

But I'm happy for Rik to decide.

-- David

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