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:
Damian Conway
Date:
August 22, 2012 17:38
Subject:
Re: Re: fixing smartmatch just hard enough (and when, too)
Message ID:
CAATtAp5oZU7mC-8HPmd2aMcAUcbShtsTFYWt9JrQCdDZ4f6F1g@mail.gmail.com
Rick SMS'd from the Bahamas:

>> [ most of table elided ]
>>     Any      Any                   undef (with fatalizable warning)
>
> I agree, including with the spirit of this one quoted line, although it
> should be "false" and not "undef." :-)

I was actually hoping that all the other cases would return the standard
"" on failure, and that this final case would (uniquely) be
defined to explicitly return undef.

That way, you could easily check whether a given smartmatch failed
meaningfully, or whether (as it were) smartmatching itself failed:

    my $matched = $x ~~ $y // die "Couldn't smartmatch $a against $b";

Or maybe even:

    use autodie '~~';
    my $matched = $x ~~ $y;


Just a thought,

Damian

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