Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update all &infix:<cmp> operators to return Order::Decrease/Same/Incr…

…ease.
  • Loading branch information...
commit 5541810090f7c0e7a5d0685430d31d008645557d 1 parent dfea6b3
Patrick R. Michaud pmichaud authored
7 src/core/Any.pm
View
@@ -236,13 +236,6 @@ multi infix:<===>($a, $b) {
nqp::p6bool(nqp::iseq_s(nqp::unbox_s($a.WHICH), nqp::unbox_s($b.WHICH)))
}
-proto infix:<cmp>($, $) { * }
-multi infix:<cmp>(\$a, \$b) {
- return -1 if $a === -$Inf || $b === $Inf;
- return 1 if $a === $Inf || $b === -$Inf;
- $a.Stringy cmp $b.Stringy
-}
-
proto infix:<before>(|$) { * }
multi infix:<before>($x?) { Bool::True }
multi infix:<before>(\$a, \$b) { ($a cmp $b) < 0 }
17 src/core/Int.pm
View
@@ -147,23 +147,6 @@ multi infix:<gcd>(int $a, int $b) returns int {
nqp::gcd_i($a, $b)
}
-## Order enumeration, for cmp and <=>
-my enum Order (:Increase(-1), :Same(0), :Decrease(1));
-
-multi infix:<cmp>(Int:D \$a, Int:D \$b) {
- Order.(nqp::p6box_i(nqp::cmp_I(nqp::p6decont($a), nqp::p6decont($b))))
-}
-multi infix:<cmp>(int $a, int $b) {
- Order.(nqp::p6box_i(nqp::cmp_i($a, $b)))
-}
-
-multi infix:«<=>»(Int:D \$a, Int:D \$b) {
- Order.(nqp::p6box_i(nqp::cmp_I(nqp::p6decont($a), nqp::p6decont($b))))
-}
-multi infix:«<=>»(int $a, int $b) {
- Order.(nqp::p6box_i(nqp::cmp_i($a, $b)))
-}
-
multi infix:<===>(Int:D \$a, Int:D \$b) {
nqp::p6bool(nqp::iseq_I(nqp::p6decont($a), nqp::p6decont($b)))
}
25 src/core/Order.pm
View
@@ -0,0 +1,25 @@
+## Order enumeration, for cmp and <=>
+my enum Order (:Increase(-1), :Same(0), :Decrease(1));
+
+proto infix:<cmp>($, $) { * }
+multi infix:<cmp>(\$a, \$b) {
+ return Order::Increase if $a === -$Inf || $b === $Inf;
+ return Order::Decrease if $a === $Inf || $b === -$Inf;
+ $a.Stringy cmp $b.Stringy
+}
+multi infix:<cmp>(Real \$a, Real \$b) { $a.Bridge cmp $b.Bridge }
+multi infix:<cmp>(Int:D \$a, Int:D \$b) {
+ Order.(nqp::p6box_i(nqp::cmp_I(nqp::p6decont($a), nqp::p6decont($b))))
+}
+multi infix:<cmp>(int $a, int $b) {
+ Order.(nqp::p6box_i(nqp::cmp_i($a, $b)))
+}
+
+multi infix:«<=>»(Int:D \$a, Int:D \$b) {
+ Order.(nqp::p6box_i(nqp::cmp_I(nqp::p6decont($a), nqp::p6decont($b))))
+}
+multi infix:«<=>»(int $a, int $b) {
+ Order.(nqp::p6box_i(nqp::cmp_i($a, $b)))
+}
+
+
2  src/core/Real.pm
View
@@ -107,8 +107,6 @@ multi infix:«>»(Real \$a, Real \$b) { $a.Bridge > $b.Bridge }
multi infix:«>=»(Real \$a, Real \$b) { $a.Bridge >= $b.Bridge }
-multi infix:<cmp>(Real \$a, Real \$b) { $a.Bridge cmp $b.Bridge }
-
proto sub infix:<mod>(|$) {*}
multi sub infix:<mod>(Real $a, Real $b) {
$a - ($a div $b) * $b;
1  tools/build/Makefile.in
View
@@ -179,6 +179,7 @@ CORE_SOURCES = \
src/core/Numeric.pm \
src/core/Real.pm \
src/core/Int.pm \
+ src/core/Order.pm \
src/core/Num.pm \
src/core/Str.pm \
src/core/Capture.pm \
Please sign in to comment.
Something went wrong with that request. Please try again.