Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove all existing numeric ACCEPTS methods in place of one new Numer…
…ic.ACCEPTS method. (Will replace a few of the older ones in a future patch, for efficiency's sake.)
  • Loading branch information
colomon committed Jun 20, 2010
1 parent 63b92f6 commit e298e50
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 36 deletions.
8 changes: 0 additions & 8 deletions src/core/Complex.pm
Expand Up @@ -6,14 +6,6 @@ class Complex does Numeric is Cool {
self.bless(*, :re($re), :im($im));
}

multi method ACCEPTS(Complex $topic) {
($topic.re ~~ $.re) && ($topic.im ~~ $.im);
}

multi method ACCEPTS($topic) {
($topic.Num ~~ $.re) && ($.im == 0);
}

method reals() {
(self.re, self.im);
}
Expand Down
8 changes: 0 additions & 8 deletions src/core/Int.pm
Expand Up @@ -14,14 +14,6 @@ our sub upgrade_to_num_if_needed($test) {
}

augment class Int does Real {
multi method ACCEPTS(Int $other) {
self == $other;
}

multi method ACCEPTS($other) {
self.Num.ACCEPTS($other);
}

method Bridge() {
self.Num;
}
Expand Down
16 changes: 0 additions & 16 deletions src/core/Num.pm
@@ -1,22 +1,6 @@
class Complex { ... }

augment class Num does Real {
multi method ACCEPTS($other) {
if self eq 'NaN' {
$other eq 'NaN';
} else {
$other == self;
}
}

multi method ACCEPTS(Complex $other) {
if self eq 'NaN' {
$other.re eq 'NaN' || $other.im eq 'NaN';
} else {
$other.im == 0 && $other.re == self;
}
}

method Bridge() {
self;
}
Expand Down
10 changes: 10 additions & 0 deletions src/core/Numeric.pm
@@ -1,4 +1,14 @@
role Numeric {
multi method ACCEPTS($other) {
my @a = self.reals;
my @b = (+$other).reals;
if @a.grep("NaN").elems > 0 {
@b.grep("NaN").elems > 0;
} else {
$other == self;
}
}

method Numeric() {
self;
}
Expand Down
4 changes: 0 additions & 4 deletions src/core/Rat.pm
Expand Up @@ -21,10 +21,6 @@ class Rat is Cool does Real {

multi method nude() { $.numerator, $.denominator; }

multi method ACCEPTS($other) {
self.Num.ACCEPTS($other);
}

multi method perl() { "$!numerator/$!denominator"; }

method Bridge() {
Expand Down

0 comments on commit e298e50

Please sign in to comment.