T
tuser
In Perl 6, I find the following about smart matching:
http://perlcabal.org/syn/S03.html#Smart_matching
$_ X Type of Match Implied Match if (given $_)
====== ===== ===================== ===================
[...]
Any Num numeric equality +$_ == X
Any Str string equality ~$_ eq X
[...]
====== ===== ===================== ===================
That means in Perl 6:
=====================
case #A1: 2 ~~ 2.0 translates into 2 == 2.0 ==> true
case #A2: 2 ~~ '2.0' translates into 2 eq '2.0' ==> false
In perl 5.10.1, I find the following about smart matching:
http://search.cpan.org/~dapm/perl-5.10.1-RC1/pod/perlsyn.pod#Smart_matching_in_detail
$a $b Type of Match Implied Matching Code
====== ===== ===================== =============
[...]
Any Num numeric equality $a == $b
Num numish[4] numeric equality $a == $b
[...]
Any Any string equality $a eq $b
====== ===== ===================== =============
[4] either a real number, or a string that looks like a number
That means in Perl 5.10.1:
==========================
case #B1: 2 ~~ 2.0 translates into 2 == 2.0 ==> true
case #B2: 2 ~~ '2.0' translates into 2 == '2.0' ==> true
The question I have is:
Why is 2 ~~ '2.0' false in Perl 6 (case #A2), whereas the identical
expression in Perl 5.10.1 (case #B2) is true ?
Or in other words:
Why is there a rule in Perl 5.10.1 ("Num numish numeric equality"),
where there is no equivalent in Perl 6 ?
http://perlcabal.org/syn/S03.html#Smart_matching
$_ X Type of Match Implied Match if (given $_)
====== ===== ===================== ===================
[...]
Any Num numeric equality +$_ == X
Any Str string equality ~$_ eq X
[...]
====== ===== ===================== ===================
That means in Perl 6:
=====================
case #A1: 2 ~~ 2.0 translates into 2 == 2.0 ==> true
case #A2: 2 ~~ '2.0' translates into 2 eq '2.0' ==> false
In perl 5.10.1, I find the following about smart matching:
http://search.cpan.org/~dapm/perl-5.10.1-RC1/pod/perlsyn.pod#Smart_matching_in_detail
$a $b Type of Match Implied Matching Code
====== ===== ===================== =============
[...]
Any Num numeric equality $a == $b
Num numish[4] numeric equality $a == $b
[...]
Any Any string equality $a eq $b
====== ===== ===================== =============
[4] either a real number, or a string that looks like a number
That means in Perl 5.10.1:
==========================
case #B1: 2 ~~ 2.0 translates into 2 == 2.0 ==> true
case #B2: 2 ~~ '2.0' translates into 2 == '2.0' ==> true
The question I have is:
Why is 2 ~~ '2.0' false in Perl 6 (case #A2), whereas the identical
expression in Perl 5.10.1 (case #B2) is true ?
Or in other words:
Why is there a rule in Perl 5.10.1 ("Num numish numeric equality"),
where there is no equivalent in Perl 6 ?