Skip to content

Commit

Permalink
can't use 'is export' on method sin because it kills multi dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Lenz committed Sep 30, 2009
1 parent cec4b04 commit 65af3ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/setting/Any-num.pm
Expand Up @@ -89,7 +89,7 @@ class Any is also {
}
}
our Num multi method sin($base = 'radians') is export {
our Num multi method sin($base = 'radians') {
self.Num.sin($base);
}

Expand Down Expand Up @@ -195,6 +195,7 @@ multi sub abs($x) { (+$x).abs() }
multi sub exp($x) { $x.Num.exp() }
multi sub log($x) { $x.Num.log() }
multi sub log10($x) { $x.Num.log10 }
multi sub sin($x, $base = 'radians') { $x.sin($base) }

our Num sub rand (*@args) {
die "too many arguments passed - 0 params expected" if @args;
Expand Down
22 changes: 15 additions & 7 deletions src/setting/Complex.pm
Expand Up @@ -24,13 +24,13 @@ class Complex {
Complex.new($.re.Num.exp * $.im.Num.cos, $.re.Num.exp * $.im.Num.sin);
}

# multi method sin($base = 'radians') {
# $.re.sin($base) * $.im.cosh($base) + ($.re.cos($base) * $.im.sinh($base))i;
# }
#
# multi method cos($base = 'radians') {
# $.re.cos($base) * $.im.cosh($base) - ($.re.sin($base) * $.im.sinh($base))i;
# }
multi method sin($base = 'radians') {
$.re.sin($base) * $.im.cosh($base) + ($.re.cos($base) * $.im.sinh($base))i;
}

multi method cos($base = 'radians') {
$.re.cos($base) * $.im.cosh($base) - ($.re.sin($base) * $.im.sinh($base))i;
}

multi method log() {
Q:PIR {
Expand Down Expand Up @@ -120,6 +120,7 @@ class Complex {
(1.0 / self).atanh!to-radians($base);
}
multi method Num { die "You can't just coerce a Complex to Num" }
}
multi sub abs(Complex $x) { $x.abs }
Expand Down Expand Up @@ -208,4 +209,11 @@ multi sub exp(Complex $x) {
$x.exp()
}

multi sub sin(Complex $x) {
$x.sin();
}
multi sub sin(Complex $x, $base) {
$x.sin($base);
}

# vim: ft=perl6

0 comments on commit 65af3ca

Please sign in to comment.