Skip to content

Commit

Permalink
Refactor infix:<===> to be built using a new Niecza::ValueIdentity su…
Browse files Browse the repository at this point in the history
…b, which can take Mu arguments. Then use Niecza::ValueIdentity where we were previously using infix:<===> in infix:<cmp>.
  • Loading branch information
colomon committed Feb 26, 2012
1 parent f8c5ab8 commit 834f2d9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/CORE.setting
Expand Up @@ -1278,12 +1278,14 @@ sub trim-leading($string) is pure { $string.trim-leading };
sub trim-trailing($string) is pure { $string.trim-trailing };
sub trim($string) is pure { $string.trim };
sub infix:<===>($l, $r) is equiv<==> {
sub Niecza::ValueIdentity(Mu $l, Mu $r) {
my $lw = $l.WHICH;
my $rw = $r.WHICH;
Q:CgOp { (box Bool (compare == (@ {$lw.ref}) (@ {$rw.ref}))) } &&
$lw.str eq $rw.str
}
sub infix:<===>($l, $r) is equiv<==> { Niecza::ValueIdentity($l, $r) }
sub infix:<=:=>(\l,\r) is equiv<==> { Q:CgOp {
(box Bool (compare == {l} {r}))
} }
Expand Down Expand Up @@ -3196,7 +3198,7 @@ sub infix:<cmp> is equiv<leg> (Mu $a, Mu $b) {
}
return ($a ~~ Real ?? "Real" !! $a.WHAT.gist) leg
($b ~~ Real ?? "Real" !! $b.WHAT.gist)
unless $a.WHAT.gist eq $b.WHAT.gist;
unless Niecza::ValueIdentity($a.WHAT, $b.WHAT);
return 0 if !$a.defined && !$b.defined;
return $a leg $b if $a ~~ Str;
return $a.key cmp $b.key || $a.value cmp $b.value if $a ~~ Pair;
Expand Down

0 comments on commit 834f2d9

Please sign in to comment.