develooper Front page | perl.perl5.porters | Postings from September 2015

Re: smartmatch needs your eyes

Thread Previous | Thread Next
From:
Father Chrysostomos
Date:
September 21, 2015 00:25
Subject:
Re: smartmatch needs your eyes
Message ID:
20150921002517.14693.qmail@lists-nntp.develooper.com
Aristotle wrote:
> In $x ~~ $y with $y eq 42 you cannot tell whether the user wanted the
> smartmatch to mean $x == 42 or $x eq 42. You can only tell that when the
> user has given you a literal 42 vs a literal '42'.

The Last Time Round, someone pointed out that the only really logical
way out of this is just to do eq, not ==/eq based on whether the rhs
is a number or string.

One big complaint was that, if you can write when(42), then
$x=42;when($x) should do the same thing.

And since Perl 5, unlike Perl 6, does not (or is not meant to) distin-
guish between strings and numbers, it just saves everybody a lot of
pain to man when(42) to string comparison.  It will still cover 90% of
the cases where people use it.  (But, of course, 110% of statistics
are made up on the spot.)


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