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

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

Thread Previous | Thread Next
David E. Wheeler
August 22, 2012 13:34
Re: fixing smartmatch just hard enough (and when, too)
Message ID:
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.


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