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

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

Thread Previous | Thread Next
From:
David E. Wheeler
Date:
August 22, 2012 13:34
Subject:
Re: fixing smartmatch just hard enough (and when, too)
Message ID:
9C60E649-5FB8-4F9B-98DB-7E52CF5A89CA@justatheory.com
On Aug 22, 2012, at 5:59 AM, David Golden wrote:

> I'm very happy with the summary and proposal

Me too. +1

> with the exception of this piece.  Rarely in Perl do we die on ambiguity and I can't think of any case involving scalar string/number mutability.  (E.g. perldata is pretty clear about not needing to worry about such conversions.)

I think it might be time we started. In the past we avoided this by having operators to disambiguate (eq vs ==). Such is not possible here: there are no separate string and number smartmatch operators (such would defeat the purpose).

> I would prefer the Any ~~ AmbiguousScalar case to warn and fall back to string comparison.  If someone wants to die on ambiguity, they can make the warning fatal.
> 
> I think this gentler approach would be more Perlish.

And I would prefer the fatality over an easily-missed ambiguity warning. I want to know when it's doing something ambiguous ASAP, so I can fix it and move on. The fix will always be simple.

Best,

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