New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multimethods for Complex. #144
Comments
From @bacekHello. There is implementation of prefix:+, prefix:-, sqrt, exp for Complex. More to come. -- |
From @bacekcomplex.diffdiff --git a/languages/perl6/src/builtins/math.pir b/languages/perl6/src/builtins/math.pir
index 1edd996..229648e 100644
--- a/languages/perl6/src/builtins/math.pir
+++ b/languages/perl6/src/builtins/math.pir
@@ -123,12 +123,18 @@ C<$x ** 0.5>
=cut
-.sub 'sqrt'
+.sub 'sqrt' :multi(_)
.param num a
a = sqrt a
.return (a)
.end
+.sub 'sqrt' :multi(Complex)
+ .param pmc a
+ a = sqrt a
+ .return (a)
+.end
+
=item truncate
@@ -172,12 +178,18 @@ constant I<e>.
=cut
-.sub 'exp'
+.sub 'exp' :multi(_)
.param num a
a = exp a
.return (a)
.end
+.sub 'exp' :multi(Complex)
+ .param pmc a
+ a = exp a
+ .return (a)
+.end
+
=item log
diff --git a/languages/perl6/src/builtins/op.pir b/languages/perl6/src/builtins/op.pir
index 4d072fc..e8b4a29 100644
--- a/languages/perl6/src/builtins/op.pir
+++ b/languages/perl6/src/builtins/op.pir
@@ -80,6 +80,11 @@ src/builtins/op.pir - Perl6 builtin operators
.return (a)
.end
+.sub 'prefix:+' :multi('Complex')
+ .param pmc a
+ .return (a)
+.end
+
.sub 'prefix:-' :multi(_)
.param num a
@@ -94,6 +99,12 @@ src/builtins/op.pir - Perl6 builtin operators
.return ($I0)
.end
+.sub 'prefix:-' :multi('Complex')
+ .param pmc a
+ a = neg a
+ .return (a)
+.end
+
.sub 'prefix:~' :multi(_)
.param string a
|
From @moritzVasily Chekalkin (via RT) wrote:
I noticed that you put these into the same files as their non-Complex What's the general policy for that? Just like this, and Complex-only Cheers, -- |
The RT System itself - Status changed from 'new' to 'open' |
From @pmichaudOn Wed, Jun 25, 2008 at 09:27:18AM -0700, Moritz Lenz via RT wrote:
Short answer: We're still working out the policy for this. Many operators With the recent class restructures we have a clearer idea than before, In this specific instance I'd prefer that the Complex operator Pm |
From @pmichaudOn Wed, Jun 25, 2008 at 12:19:13PM -0500, Patrick R. Michaud wrote:
Another possibility would be to have the operators always use the This is one of those areas where Parrot gets a little confusing -- Pm |
From @moritzAnother question: Vasily Chekalkin (via RT) wrote:
Do we actually want a sqrt(Complex)? Somebody who is sufficiently Any thoughts? Moritz -- |
From @moritzResolved in r28924, (with patch partly applied to Thank you very much for your contribution. |
@moritz - Status changed from 'open' to 'resolved' |
From @bacekOn Tue Jul 01 15:20:03 2008, moritz wrote:
You've put exp and sqrt in wrong namespace :) Attached patch fix it. S29-num/exp.t is #pure. Last 2 tests in -- |
From @bacekcomplex.diffdiff --git a/languages/perl6/src/classes/Complex.pir b/languages/perl6/src/classes/Complex.pir
index 3f714f3..a275a58 100644
--- a/languages/perl6/src/classes/Complex.pir
+++ b/languages/perl6/src/classes/Complex.pir
@@ -45,26 +45,6 @@ Returns a Perl representation of the Complex.
=over 4
-=item exp
-
-=cut
-
-.sub 'exp' :multi(Complex)
- .param pmc a
- a = exp a
- .return(a)
-.end
-
-=item sqrt
-
-=cut
-
-.sub 'sqrt' :multi(Complex)
- .param pmc a
- a = sqrt a
- .return (a)
-.end
-
=back
@@ -190,6 +170,27 @@ Returns a Perl representation of the Complex.
.return ($P0)
.end
+
+=item exp
+
+=cut
+
+.sub 'exp' :multi(Complex)
+ .param pmc a
+ a = exp a
+ .return(a)
+.end
+
+=item sqrt
+
+=cut
+
+.sub 'sqrt' :multi(Complex)
+ .param pmc a
+ a = sqrt a
+ .return (a)
+.end
+
=back
=cut
|
@bacek - Status changed from 'resolved' to 'open' |
From @pmichaudOn Wed Jun 25 10:19:36 2008, pmichaud wrote:
Just for the record (and for future patch contributors), I modified my Pm |
From @pmichaudResolved in r29045 (by making exp and sqrt into exported methods of Pm |
@pmichaud - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#56230 (status was 'resolved')
Searchable as RT56230$
The text was updated successfully, but these errors were encountered: