Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
switch protos to use | instead of |$
  • Loading branch information
moritz committed Aug 13, 2012
1 parent b6bfd77 commit 53c7856
Show file tree
Hide file tree
Showing 26 changed files with 229 additions and 229 deletions.
68 changes: 34 additions & 34 deletions src/core/Any.pm
Expand Up @@ -111,13 +111,13 @@ my class Any {
:excludes_max($excludes_max));
}

proto method push(|$) { * }
proto method push(|) { * }
multi method push(Any:U \$self: *@values) {
&infix:<=>($self, Array.new);
$self.push(@values);
}

proto method tree(|$) { * }
proto method tree(|) { * }
multi method tree(Any:U:) { self }
multi method tree(Any:D:) { self.lol }
multi method tree(Any:D: Cool $count as Int) {
Expand All @@ -131,13 +131,13 @@ my class Any {
MapIter.new(self.list, { .&c.item }, Mu).list
}

proto method unshift(|$) { * }
proto method unshift(|) { * }
multi method unshift(Any:U \$self: *@values) {
&infix:<=>($self, Array.new);
$self.unshift(@values);
}

proto method postcircumfix:<[ ]>(|$) { * }
proto method postcircumfix:<[ ]>(|) { * }
multi method postcircumfix:<[ ]>() { self.list }
multi method postcircumfix:<[ ]>(:$BIND!) {
X::Bind::ZenSlice.new(type => self.WHAT).throw
Expand Down Expand Up @@ -185,7 +185,7 @@ my class Any {
X::Bind::Slice.new(type => self.WHAT).throw;
}

proto method at_pos(|$) {*}
proto method at_pos(|) {*}
multi method at_pos(Any:D: $pos) {
fail X::OutOfRange.new(
what => 'Index',
Expand All @@ -208,7 +208,7 @@ my class Any {
########
# Hash-like methods for Any.
########
proto method postcircumfix:<{ }>(|$) { * }
proto method postcircumfix:<{ }>(|) { * }
multi method postcircumfix:<{ }>() { self }
multi method postcircumfix:<{ }>(:$BIND!) {
X::Bind::ZenSlice.new(type => self.WHAT).throw
Expand All @@ -234,7 +234,7 @@ my class Any {
X::Bind::Slice.new(type => self.WHAT).throw
}

proto method at_key(|$) { * }
proto method at_key(|) { * }
multi method at_key(Any:D: $key) {
fail "postcircumfix:<\{ \}> not defined for type {self.WHAT.perl}";
}
Expand All @@ -260,96 +260,96 @@ multi infix:<===>($a, $b) {
nqp::p6bool(nqp::iseq_s(nqp::unbox_s($a.WHICH), nqp::unbox_s($b.WHICH)))
}

proto infix:<before>(|$) { * }
proto infix:<before>(|) { * }
multi infix:<before>($x?) { Bool::True }
multi infix:<before>(\$a, \$b) { ($a cmp $b) < 0 }

proto infix:<after>(|$) { * }
proto infix:<after>(|) { * }
multi infix:<after>($x?) { Bool::True }
multi infix:<after>(\$a, \$b) { ($a cmp $b) > 0 }

# XXX: should really be '$a is rw' (no \) in the next four operators
proto prefix:<++>(|$) { * }
proto prefix:<++>(|) { * }
multi prefix:<++>(Mu:D \$a is rw) { $a = $a.succ }
multi prefix:<++>(Mu:U \$a is rw) { $a = 1 }
proto prefix:<-->(|$) { * }
proto prefix:<-->(|) { * }
multi prefix:<-->(Mu:D \$a is rw) { $a = $a.pred }
multi prefix:<-->(Mu:U \$a is rw) { $a = -1 }

proto postfix:<++>(|$) { * }
proto postfix:<++>(|) { * }
multi postfix:<++>(Mu:D \$a is rw) { my $b = $a; $a = $a.succ; $b }
multi postfix:<++>(Mu:U \$a is rw) { $a = 1; 0 }
proto postfix:<-->(|$) { * }
proto postfix:<-->(|) { * }
multi postfix:<-->(Mu:D \$a is rw) { my $b = $a; $a = $a.pred; $b }
multi postfix:<-->(Mu:U \$a is rw) { $a = -1; 0 }

proto infix:<min>(|$) { * }
proto infix:<min>(|) { * }
multi infix:<min>(*@args) { @args.min }
# XXX the multi version suffers from a multi dispatch bug
# where the mandatory named is ignored in the presence of a slurpy
#proto sub min(|$) { * }
#proto sub min(|) { * }
#multi sub min(*@args) { @args.min() }
#multi sub min(*@args, :&by!) { @args.min(&by) }
sub min(*@args, :&by = &infix:<cmp>) { @args.min(&by) }


proto infix:<max>(|$) { * }
proto infix:<max>(|) { * }
multi infix:<max>(*@args) { @args.max }
#proto sub max(|$) { * }
#proto sub max(|) { * }
#multi sub max(*@args) { @args.max() }
#multi sub max(*@args, :&by!) { @args.max(&by) }
sub max(*@args, :&by = &infix:<cmp>) { @args.max(&by) }

proto infix:<minmax>(|$) { * }
proto infix:<minmax>(|) { * }
multi infix:<minmax>(*@args) { @args.minmax }
#proto sub minmax(|$) { * }
#proto sub minmax(|) { * }
#multi sub minmax(*@args) { @args.minmax() }
#multi sub minmax(*@args, :&by!) { @args.minmax(&by) }
sub minmax(*@args, :&by = &infix:<cmp>) { @args.minmax(&by) }

proto map(|$) {*}
proto map(|) {*}
multi map(&code, *@values) { @values.map(&code) }

proto grep(|$) {*}
proto grep(|) {*}
multi grep(Mu $test, *@values) { @values.grep($test) }

proto first(|$) {*}
proto first(|) {*}
multi first(Mu $test, *@values) { @values.first($test) }

proto join(|$) { * }
proto join(|) { * }
multi join($sep = '', *@values) { @values.join($sep) }

proto pick(|$) { * }
proto pick(|) { * }
multi pick($n, *@values) { @values.pick($n) }

proto roll(|$) { * }
proto roll(|) { * }
multi roll($n, *@values) { @values.roll($n) }

proto keys(|$) { * }
proto keys(|) { * }
multi keys($x) { $x.keys }

proto values(|$) { * }
proto values(|) { * }
multi values($x) { $x.values }

proto pairs(|$) { * }
proto pairs(|) { * }
multi pairs($x) { $x.pairs }

proto kv(|$) { * }
proto kv(|) { * }
multi kv($x) { $x.kv }

proto elems(|$) { * }
proto elems(|) { * }
multi elems($a) { $a.elems }

proto end(|$) { * }
proto end(|) { * }
multi end($a) { $a.end }

proto classify(|$) { * }
proto classify(|) { * }
multi classify(&test, *@items) { @items.classify(&test) }

proto uniq(|$) { * }
proto uniq(|) { * }
multi uniq(*@values) { @values.uniq }

proto sub sort(|$) {*}
proto sub sort(|) {*}
multi sub sort(*@values) {
@values.at_pos(0).^does(Callable)
?? do { my $cmp := @values.shift; @values.sort($cmp) }
Expand Down
6 changes: 3 additions & 3 deletions src/core/Array.pm
@@ -1,7 +1,7 @@
class Array {
# Has attributes and parent List declared in BOOTSTRAP.

method new(|$) {
method new(|) {
my Mu $args := pir::perl6_current_args_rpa__P();
nqp::shift($args);
nqp::p6list($args, self.WHAT, Bool::True);
Expand Down Expand Up @@ -29,7 +29,7 @@ class Array {
-> { nqp::bindpos($items, $pos, $v) } )
}

proto method bind_pos(|$) { * }
proto method bind_pos(|) { * }
multi method bind_pos($pos is copy, \$bindval) is rw {
$pos = $pos.Int;
self.gimme($pos + 1);
Expand Down Expand Up @@ -83,7 +83,7 @@ class Array {
nqp::findmethod(List, 'STORE_AT_POS')(self, $pos, $v);
}

method STORE(|$) {
method STORE(|) {
# get arguments, shift off invocant
my $args := pir::perl6_current_args_rpa__P();
nqp::shift($args);
Expand Down
2 changes: 1 addition & 1 deletion src/core/Backtrace.pm
Expand Up @@ -25,7 +25,7 @@ my class Backtrace::Frame {
}

my class Backtrace is List {
proto method new(|$) {*}
proto method new(|) {*}

multi method new(Exception $e, Int $offset = 0) {
self.new(nqp::getattr(nqp::p6decont($e), Exception, '$!ex').backtrace, $offset);
Expand Down
22 changes: 11 additions & 11 deletions src/core/Bool.pm
Expand Up @@ -48,29 +48,29 @@ multi prefix:<not>(Mu \$a) { nqp::p6bool($a.Bool ?? 0 !! 1) }
proto prefix:<?^>(Mu $) { * }
multi prefix:<?^>(Mu \$a) { not $a }

proto infix:<?&>(|$) { * }
proto infix:<?&>(|) { * }
multi infix:<?&>(Mu $x = Bool::True) { $x.Bool }
multi infix:<?&>(Mu \$a, Mu \$b) { $a.Bool && $b.Bool }

proto infix:<?|>(|$) { * }
proto infix:<?|>(|) { * }
multi infix:<?|>(Mu $x = Bool::False) { $x.Bool }
multi infix:<?|>(Mu \$a, Mu \$b) { $a.Bool || $b.Bool }

proto infix:<?^>(|$) { * }
proto infix:<?^>(|) { * }
multi infix:<?^>(Mu $x = Bool::False) { $x.Bool }
multi infix:<?^>(Mu \$a, Mu \$b) { $a.Bool ^^ $b.Bool }

# These operators are normally handled as macros in the compiler;
# we define them here for use as arguments to functions.
proto infix:<&&>(|$) { * }
proto infix:<&&>(|) { * }
multi infix:<&&>(Mu $x = Bool::True) { $x }
multi infix:<&&>(Mu \$a, Mu \$b) { $a && $b }

proto infix:<||>(|$) { * }
proto infix:<||>(|) { * }
multi infix:<||>(Mu $x = Bool::False) { $x }
multi infix:<||>(Mu \$a, Mu \$b) { $a || $b }

proto infix:<^^>(|$) { * }
proto infix:<^^>(|) { * }
multi infix:<^^>(Mu $x = Bool::False) { $x }
multi infix:<^^>(Mu \$a, Mu \$b) { $a ^^ $b }
multi infix:<^^>(*@a) {
Expand All @@ -84,23 +84,23 @@ multi infix:<^^>(*@a) {
$a;
}

proto infix:<//>(|$) { * }
proto infix:<//>(|) { * }
multi infix:<//>(Mu $x = Any) { $x }
multi infix:<//>(Mu \$a, Mu \$b) { $a // $b }

proto infix:<and>(|$) { * }
proto infix:<and>(|) { * }
multi infix:<and>(Mu $x = Bool::True) { $x }
multi infix:<and>(Mu \$a, Mu \$b) { $a && $b }

proto infix:<or>(|$) { * }
proto infix:<or>(|) { * }
multi infix:<or>(Mu $x = Bool::False) { $x }
multi infix:<or>(Mu \$a, Mu \$b) { $a || $b }

proto infix:<xor>(|$) { * }
proto infix:<xor>(|) { * }
multi infix:<xor>(Mu $x = Bool::False) { $x }
multi infix:<xor>(Mu \$a, Mu \$b) { $a ^^ $b }
multi infix:<xor>(*@a) { &infix:<^^>(@a); }

proto infix:<orelse>(|$) { * }
proto infix:<orelse>(|) { * }
multi infix:<orelse>(Mu $x = Any) { $x }
multi infix:<orelse>(Mu \$a, Mu \$b) { $a // $b }
4 changes: 2 additions & 2 deletions src/core/Complex.pm
Expand Up @@ -2,7 +2,7 @@ my class Complex is Cool does Numeric {
has num $.re;
has num $.im;

proto method new(|$) { * }
proto method new(|) { * }
multi method new(Real \$re, Real \$im) {
my $new = nqp::create(self);
$new.BUILD($re.Num, $im.Num);
Expand Down Expand Up @@ -396,7 +396,7 @@ multi sub infix:<==>(Complex:D \$a, Complex:D \$b) returns Bool:D { $a.re == $b.
multi sub infix:<==>(Complex:D \$a, Real \$b) returns Bool:D { $a.re == $b && $a.im == 0e0 }
multi sub infix:<==>(Real \$a, Complex:D \$b) returns Bool:D { $a == $b.re && 0e0 == $b.im }

proto postfix:<i>(|$) returns Complex:D { * }
proto postfix:<i>(|) returns Complex:D { * }
multi postfix:<i>(Real \$a) returns Complex:D { Complex.new(0e0, $a); }
multi postfix:<i>(Complex:D \$a) returns Complex:D { Complex.new(-$a.im, $a.re) }
multi postfix:<i>(Numeric \$a) returns Complex:D { $a * Complex.new(0e0, 1e0) }
Expand Down
26 changes: 13 additions & 13 deletions src/core/Cool.pm
Expand Up @@ -36,11 +36,11 @@ my class Cool {
method acotanh() { self.Numeric.acotanh }
method cis() { self.Numeric.cis }

proto method log(|$) {*}
proto method log(|) {*}
multi method log(Cool:D: ) { self.Numeric.log }
multi method log(Cool:D: $base) { self.Numeric.log($base.Numeric) }

proto method exp(|$) {*}
proto method exp(|) {*}
multi method exp(Cool:D: ) { self.Numeric.exp }
multi method exp(Cool:D: $base) { self.Numeric.exp($base.Numeric) }

Expand Down Expand Up @@ -112,7 +112,7 @@ my class Cool {
}
method trans(*@a) { self.Str.trans(@a) }

proto method index(|$) {*}
proto method index(|) {*}
multi method index(Cool $needle, Cool $pos = 0) {
if $needle eq '' {
my $chars = self.chars;
Expand All @@ -127,7 +127,7 @@ my class Cool {
$result < 0 ?? Int !! $result;
}

proto method rindex(|$) {*}
proto method rindex(|) {*}
multi method rindex(Cool $needle, Cool $pos?) {
if $needle eq '' {
return $pos.defined && $pos < self.chars
Expand All @@ -151,23 +151,23 @@ my class Cool {
}

method ords(Cool:D:) { self.Str.ords }
proto method split(|$) {*}
proto method split(|) {*}
multi method split(Regex $pat, $limit = $Inf, :$all) {
self.Stringy.split($pat, $limit, :$all);
}
multi method split(Cool $pat, $limit = $Inf, :$all) {
self.Stringy.split($pat.Stringy, $limit, :$all);
}
proto method match(|$) {*}
proto method match(|) {*}
multi method match(Cool:D: $target, *%adverbs) {
self.Stringy.match($target, |%adverbs)
}

proto method comb(|$) {*}
proto method comb(|) {*}
multi method comb() { self.Str.comb() }
multi method comb(Regex $matcher, $limit = $Inf) { self.Str.comb($matcher, $limit) }

proto method subst(|$) {*}
proto method subst(|) {*}
multi method subst($matcher, $replacement, *%adverbs) {
self.Stringy.subst($matcher, $replacement, |%adverbs);
}
Expand Down Expand Up @@ -203,21 +203,21 @@ sub uc(Cool $s) { $s.uc }

sub ucfirst(Cool $s) is DEPRECATED { $s.ucfirst }

proto sub rindex(|$) { * };
proto sub rindex(|) { * };
multi sub rindex(Cool $s, Cool $needle, Cool $pos) { $s.rindex($needle, $pos) };
multi sub rindex(Cool $s, Cool $needle) { $s.rindex($needle) };

proto sub ords(|$) { * }
proto sub ords(|) { * }
multi sub ords(Cool $s) { ords($s.Stringy) }

proto sub comb(|$) { * }
proto sub comb(|) { * }
multi sub comb(Regex $matcher, Cool $input, $limit = *) { $input.comb($matcher, $limit) }

proto sub capitalize(|$) { * }
proto sub capitalize(|) { * }
multi sub capitalize(Str:D $x) {$x.capitalize }
multi sub capitalize(Cool $x) {$x.Stringy.capitalize }

proto sub tclc(|$) { * }
proto sub tclc(|) { * }
multi sub tclc(Cool $x) { tclc $x.Str }

sub sprintf(Cool $format, *@args) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/EnumMap.pm
Expand Up @@ -25,7 +25,7 @@ my class EnumMap does Associative {
so self.keys.any.match($topic);
}

proto method exists(|$) {*}
proto method exists(|) {*}
multi method exists(EnumMap:D: Str:D \$key) {
nqp::p6bool(
nqp::defined($!storage)
Expand Down

0 comments on commit 53c7856

Please sign in to comment.