From 6cf515ba8ac53d7e97988220eba735821aea0982 Mon Sep 17 00:00:00 2001 From: Carl Masak Date: Wed, 28 Apr 2010 15:16:07 +0200 Subject: [PATCH 01/11] [ROADMAP] added self to Buf impl work Seems someone got his GSoC project accepted. \o/ --- docs/ROADMAP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ROADMAP b/docs/ROADMAP index 43301df28c7..c1aa6f0ffc2 100644 --- a/docs/ROADMAP +++ b/docs/ROADMAP @@ -35,7 +35,7 @@ Really important items 1 *** get the Advent examples running again (all) Ought to have items -2 ** basic Buf implementation (A) +2 ** basic Buf implementation (A, masak) 2 ** speed issues and profiling (C, all) 2 ** regex modifiers (B, pmichaud) 2 *** installation standards (A) From 6a502fcb6675d313df7739536128bf227c3814ae Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Wed, 28 Apr 2010 15:15:06 +0200 Subject: [PATCH 02/11] implement Any.elems to fix RT #74732 --- src/core/Any-list.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/Any-list.pm b/src/core/Any-list.pm index f8759c54a68..da8694c5f8c 100644 --- a/src/core/Any-list.pm +++ b/src/core/Any-list.pm @@ -6,6 +6,10 @@ augment class Any { pir::join__SsP($separator, self.list.eager); } + multi method elems() { + 1; + } + our multi method map(&block) { Q:PIR { .local pmc self, block, map From 72f914f44897c5a1d64287a119af8b9fa5d9dbc7 Mon Sep 17 00:00:00 2001 From: Solomon Foster Date: Wed, 28 Apr 2010 12:08:05 -0400 Subject: [PATCH 03/11] Clone the returned match so we can take it without worrying about the next iteration clobbering it. --- src/core/Cool-str.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/Cool-str.pm b/src/core/Cool-str.pm index abf42aeac9e..1bd071beb62 100644 --- a/src/core/Cool-str.pm +++ b/src/core/Cool-str.pm @@ -72,7 +72,8 @@ augment class Cool { gather { while $l-- > 0 && (my $m = self.match($matcher, :c($c))) { take self.substr($c, $m.from - $c); - take $m if $all; + my $m-clone = $m; + take $m-clone if $all; $c = $m.to == $c ?? $c + 1 !! $m.to; } take self.substr($c); From 3966c622355ec99727f6d5c0301dba2546134af5 Mon Sep 17 00:00:00 2001 From: Solomon Foster Date: Wed, 28 Apr 2010 16:28:07 -0400 Subject: [PATCH 04/11] Straighten out type issues with Real.exp. In the process, add Real * Real, Complex ** Real, and Real ** Complex. --- src/core/Complex.pm | 12 ++++++++++-- src/core/Real.pm | 14 +++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/core/Complex.pm b/src/core/Complex.pm index cdf0485fd3f..db34264dc29 100644 --- a/src/core/Complex.pm +++ b/src/core/Complex.pm @@ -286,11 +286,11 @@ multi sub infix:<*>(Complex $a, Complex $b) { Complex.new($a.re * $b.re - $a.im * $b.im, $a.im * $b.re + $a.re * $b.im); } -multi sub infix:<*>(Complex $a, $b) { +multi sub infix:<*>(Complex $a, Real $b) { Complex.new($a.re * $b, $a.im * $b); } -multi sub infix:<*>($a, Complex $b) { +multi sub infix:<*>(Real $a, Complex $b) { Complex.new($a * $b.re, $a * $b.im); } @@ -332,6 +332,14 @@ multi sub infix:<**>($a, Complex $b) { ($a.log * $b).exp; } +multi sub infix:<**>(Complex $a, Real $b) { + ($a.log * $b).exp; +} + +multi sub infix:<**>(Real $a, Complex $b) { + ($a.log * $b).exp; +} + multi sub log(Complex $x) { $x.log() } diff --git a/src/core/Real.pm b/src/core/Real.pm index 87dc57f5c2b..a9c3e7397a0 100644 --- a/src/core/Real.pm +++ b/src/core/Real.pm @@ -10,12 +10,12 @@ role Real does Numeric { } # Hmmm... should the second argument be Numeric for the next two? - method exp(Real $exponent: Real $base = e) { + method exp(Real $exponent: Numeric $base = e) { $base ** $exponent; } - method log(Real $x: Real $base = e) { - $x.Bridge.log($base.Bridge); + method log(Real $x: Numeric $base = e) { + $x.Bridge.log($base); } method sign(Real $x:) { @@ -98,6 +98,14 @@ multi sub infix:<->(Num $a, Num $b) { pir::sub__NNN($a, $b) } +multi sub infix:<*>(Real $a, Real $b) { + $a.Bridge * $b.Bridge; +} + +multi sub infix:<*>(Num $a, Num $b) { + pir::mul__NNN($a, $b) +} + multi sub infix:(Real $a, Real $b) { $a.Bridge / $b.Bridge; } From 08570984d9996a29fad7d79f3e1852263f173c10 Mon Sep 17 00:00:00 2001 From: Solomon Foster Date: Wed, 28 Apr 2010 20:40:50 -0400 Subject: [PATCH 05/11] Remove Complex ** Any and Any ** Complex, as they should no longer be needed. Change Any * Any to convert its arguments to Numeric and call multiply on them then. --- src/core/Complex.pm | 8 -------- src/core/operators.pm | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/core/Complex.pm b/src/core/Complex.pm index db34264dc29..30b1d8bd776 100644 --- a/src/core/Complex.pm +++ b/src/core/Complex.pm @@ -324,14 +324,6 @@ multi sub infix:<**>(Complex $a, Complex $b) { ($a.log * $b).exp; } -multi sub infix:<**>(Complex $a, $b) { - ($a.log * $b).exp; -} - -multi sub infix:<**>($a, Complex $b) { - ($a.log * $b).exp; -} - multi sub infix:<**>(Complex $a, Real $b) { ($a.log * $b).exp; } diff --git a/src/core/operators.pm b/src/core/operators.pm index 52c8409d882..d3ef43bb090 100644 --- a/src/core/operators.pm +++ b/src/core/operators.pm @@ -42,7 +42,7 @@ our multi sub infix:<->($a, $b) { } our multi sub infix:<*>($a, $b) { - pir::mul__NNN($a, $b) + +$a * +$b; } our multi sub infix:($a, $b) { From ed321b4087dbfeb85d355e073d680a152e5de0e4 Mon Sep 17 00:00:00 2001 From: Solomon Foster Date: Wed, 28 Apr 2010 21:36:01 -0400 Subject: [PATCH 06/11] Fix comb version of the match with take bug fixed earlier today in split. --- src/core/Cool-str.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/Cool-str.pm b/src/core/Cool-str.pm index 1bd071beb62..4445b2bb785 100644 --- a/src/core/Cool-str.pm +++ b/src/core/Cool-str.pm @@ -42,7 +42,12 @@ augment class Cool { my $c = 0; my $l = $limit ~~ ::Whatever ?? Inf !! $limit; gather while $l > 0 && (my $m = self.match($matcher, :c($c))) { - take $match ?? $m !! ~$m; + if $match { + my $m-clone = $m; + take $m-clone; + } else { + take ~$m; + } $c = $m.to == $c ?? $c + 1 !! $m.to; --$l; } From e16cf45bcfa4a7664e361c95d4c4a7592334f89b Mon Sep 17 00:00:00 2001 From: Jonathan Scott Duff Date: Wed, 28 Apr 2010 21:54:18 -0500 Subject: [PATCH 07/11] [tools] fix typo and output sorted keys --- tools/contributors.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/contributors.pl b/tools/contributors.pl index 287965a1564..54abdaf257b 100644 --- a/tools/contributors.pl +++ b/tools/contributors.pl @@ -21,7 +21,7 @@ while ($msg =~ /([^\s()]+)\+\+/g) { $contrib{nick_to_name($1)}++; } - while ($msg =~ /(couretsy by:?)\s*(\S.*)/i) { + while ($msg =~ /(courtesy by:?)\s*(\S.*)/i) { $contrib{nick_to_name($1)}++; } } @@ -67,7 +67,7 @@ sub nick_to_name_from_CREDITS { } } close $f; - use Data::Dumper; print Dumper \%nicks; + use Data::Dumper; $Data::Dumper::Sortkeys = 1; print Dumper \%nicks; return \%nicks; } From fe59fa87f315385469375c3bfa76db8ff916beea Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Thu, 29 Apr 2010 17:21:27 +0200 Subject: [PATCH 08/11] enable rx{...} quoting form. At some point we need a more general solution for these quoting mechanismsn... --- src/Perl6/Grammar.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Perl6/Grammar.pm b/src/Perl6/Grammar.pm index e12104979b2..7c5ae12b275 100644 --- a/src/Perl6/Grammar.pm +++ b/src/Perl6/Grammar.pm @@ -1298,7 +1298,13 @@ token quote:sym { 'Q' <.ws> } token quote:sym { 'Q:PIR' <.ws> } token quote:sym { '/' \s* '/' <.panic: "Null regex not allowed"> } token quote:sym { '/''/' <.old_rx_mods>? } -token quote:sym { >> '/''/' <.old_rx_mods>? } +token quote:sym { + >> + [ + | '/''/' <.old_rx_mods>? + | '{''}' <.old_rx_mods>? + ] +} token quote:sym { >> [ From 9d955f2ed5afe60721007ca47cc15280ed18ada7 Mon Sep 17 00:00:00 2001 From: Solomon Foster Date: Thu, 29 Apr 2010 10:07:56 -0400 Subject: [PATCH 09/11] Be more specific about types for Complex mixed-type math. Change Any, Any versions of the basic math functions to coerce to Numeric (instead of called PIR functions which coerce to Num). --- src/core/Complex.pm | 12 ++++++------ src/core/operators.pm | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/Complex.pm b/src/core/Complex.pm index 30b1d8bd776..cae55101703 100644 --- a/src/core/Complex.pm +++ b/src/core/Complex.pm @@ -255,11 +255,11 @@ multi sub infix:<+>(Complex $a, Complex $b) { Complex.new($a.re + $b.re, $a.im + $b.im); } -multi sub infix:<+>(Complex $a, $b) { +multi sub infix:<+>(Complex $a, Real $b) { Complex.new($a.re + $b, $a.im); } -multi sub infix:<+>($a, Complex $b) { +multi sub infix:<+>(Real $a, Complex $b) { # Was $b + $a; but that trips a ng bug, and also means # that Num + Complex is slower than Complex + Num, which # seems daft. @@ -274,11 +274,11 @@ multi sub infix:<->(Complex $a, Complex $b) { Complex.new($a.re - $b.re, $a.im - $b.im); } -multi sub infix:<->(Complex $a, $b) { +multi sub infix:<->(Complex $a, Real $b) { Complex.new($a.re - $b, $a.im); } -multi sub infix:<->($a, Complex $b) { +multi sub infix:<->(Real $a, Complex $b) { Complex.new($a - $b.re, -$b.im); } @@ -300,11 +300,11 @@ multi sub infix:(Complex $a, Complex $b) { ($a.im * $b.re - $a.re * $b.im) / $d); } -multi sub infix:(Complex $a, $b) { +multi sub infix:(Complex $a, Real $b) { Complex.new($a.re / $b, $a.im / $b); } -multi sub infix:($a, Complex $b) { +multi sub infix:(Real $a, Complex $b) { Complex.new($a, 0) / $b; } diff --git a/src/core/operators.pm b/src/core/operators.pm index d3ef43bb090..6c9cbbe9671 100644 --- a/src/core/operators.pm +++ b/src/core/operators.pm @@ -34,11 +34,11 @@ our multi sub prefix:<->($a) { } our multi sub infix:<+>($a, $b) { - pir::add__NNN($a, $b) + +$a + +$b; } our multi sub infix:<->($a, $b) { - pir::sub__NNN($a, $b) + +$a - +$b; } our multi sub infix:<*>($a, $b) { @@ -46,7 +46,7 @@ our multi sub infix:<*>($a, $b) { } our multi sub infix:($a, $b) { - pir::div__NNN($a, $b) + +$a / +$b; } our multi sub infix:<%>($a, $b) { @@ -54,7 +54,7 @@ our multi sub infix:<%>($a, $b) { } our multi sub infix:<**>($a, $b) { - pir::pow__NNN($a, $b) + (+$a) ** +$b; # parenthesis needed because of precendence. } our multi sub infix:<&>(*@items) { From 4aeb5a270c258cfb103f9d4742eaa9a26e352402 Mon Sep 17 00:00:00 2001 From: Solomon Foster Date: Thu, 29 Apr 2010 11:27:00 -0400 Subject: [PATCH 10/11] Have $a op= $b call op() to get a value for $a if $a is not defined. --- src/builtins/assign.pir | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/builtins/assign.pir b/src/builtins/assign.pir index 462c9381bbc..146eb608443 100644 --- a/src/builtins/assign.pir +++ b/src/builtins/assign.pir @@ -85,6 +85,12 @@ src/builtins/assign.pir - assignment operations $P0 = find_lex '$opname' $S0 = $P0 $P0 = get_global $S0 + $P1 = a.'defined'() + if $P1 goto defined + $P2 = $P0() + $P1 = $P0($P2, b) + .tailcall '&infix:<=>'(a, $P1) + defined: $P1 = $P0(a, b) .tailcall '&infix:<=>'(a, $P1) .end From c4857abdafc69298550c501e0903c731b13df748 Mon Sep 17 00:00:00 2001 From: Solomon Foster Date: Thu, 29 Apr 2010 14:25:38 -0400 Subject: [PATCH 11/11] Turn on zero-argument versions of infix:<~> and infix:. --- src/core/metaops.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/metaops.pm b/src/core/metaops.pm index fe48ead5e7c..7fa39734058 100644 --- a/src/core/metaops.pm +++ b/src/core/metaops.pm @@ -179,7 +179,7 @@ our multi sub infix:<*>() { 1 } our multi sub infix:<+&>() { +^0 } our multi sub infix:<+>() { 0 } our multi sub infix:<->() { 0 } -#our multi sub infix:<~>() { '' } +our multi sub infix:<~>() { '' } our multi sub infix:<+|>() { 0 } our multi sub infix:<+^>() { 0 } our multi sub infix:<~|>() { '' } @@ -209,7 +209,7 @@ our multi sub infix:() { Bool::True } our multi sub infix:<||>() { Bool::False } our multi sub infix:() { Bool::False } #our multi sub infix:<^^>() { Bool::False } -#our multi sub infix:() { Any } +our multi sub infix:() { Any } #our multi sub infix:() { +Inf } #our multi sub infix:() { -Inf } #our multi sub infix:<=>() { Nil }