Skip to content

Commit

Permalink
switch Numeric, Real and Cursor to sigilless params
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Aug 14, 2012
1 parent 1f6fe81 commit 221379e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/core/Cursor.pm
Expand Up @@ -52,7 +52,7 @@ my class Cursor does NQPCursorRole {
self."!cursor_start"()
}

method OTHERGRAMMAR($grammar, $name, |$args) {
method OTHERGRAMMAR($grammar, $name, |) {
my $lang_cursor := $grammar.'!cursor_init'(self.target(), :p(self.pos()));
$lang_cursor."$name"();
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/Numeric.pm
Expand Up @@ -32,10 +32,10 @@ multi sub infix:<eqv>(Numeric $a, Numeric $b) {
## arithmetic operators

proto prefix:<+>(|) { * }
multi prefix:<+>(\$a) { $a.Numeric }
multi prefix:<+>($a) { a.Numeric }

proto prefix:<->(|) { * }
multi prefix:<->(\$a) { -$a.Numeric }
multi prefix:<->(\a) { -a.Numeric }

proto sub abs(|) { * }
multi sub abs(\a) { abs a.Numeric }
Expand Down
34 changes: 17 additions & 17 deletions src/core/Real.pm
Expand Up @@ -88,39 +88,39 @@ my role Real does Numeric {
proto sub cis(|) {*}
multi sub cis(Real $a) { $a.cis }

multi infix:<+>(Real \$a, Real \$b) { $a.Bridge + $b.Bridge }
multi infix:<+>(Real \a, Real \b) { a.Bridge + b.Bridge }

multi infix:<->(Real \$a, Real \$b) { $a.Bridge - $b.Bridge }
multi infix:<->(Real \a, Real \b) { a.Bridge - b.Bridge }

multi infix:<*>(Real \$a, Real \$b) { $a.Bridge * $b.Bridge }
multi infix:<*>(Real \a, Real \b) { a.Bridge * b.Bridge }

multi infix:</>(Real \$a, Real \$b) { $a.Bridge / $b.Bridge }
multi infix:</>(Real \a, Real \b) { a.Bridge / b.Bridge }

multi infix:<%>(Real \$a, Real \$b) { $a.Bridge % $b.Bridge }
multi infix:<%>(Real \a, Real \b) { a.Bridge % b.Bridge }

multi infix:<**>(Real \$a, Real \$b) { $a.Bridge ** $b.Bridge }
multi infix:<**>(Real \a, Real \b) { a.Bridge ** b.Bridge }

multi infix:«<=>»(Real \$a, Real \$b) { $a.Bridge <=> $b.Bridge }
multi infix:«<=>»(Real \a, Real \b) { a.Bridge <=> b.Bridge }

multi infix:<==>(Real \$a, Real \$b) { $a.Bridge == $b.Bridge }
multi infix:<==>(Real \a, Real \b) { a.Bridge == b.Bridge }

multi infix<»(Real \$a, Real \$b) { $a.Bridge < $b.Bridge }
multi infix<»(Real \a, Real \b) { a.Bridge < b.Bridge }

multi infix<=»(Real \$a, Real \$b) { $a.Bridge <= $b.Bridge }
multi infix<=»(Real \a, Real \b) { a.Bridge <= b.Bridge }

multi infix>»(Real \$a, Real \$b) { $a.Bridge > $b.Bridge }
multi infix>»(Real \a, Real \b) { a.Bridge > b.Bridge }

multi infix>=»(Real \$a, Real \$b) { $a.Bridge >= $b.Bridge }
multi infix>=»(Real \a, Real \b) { a.Bridge >= b.Bridge }

multi prefix:<->(Real \$a) { -$a.Bridge }
multi prefix:<->(Real \a) { -a.Bridge }

proto sub infix:<mod>(|) {*}
multi sub infix:<mod>(Real $a, Real $b) {
$a - ($a.Bridge.Int div $b.Bridge.Int) * $b;
}

multi sub abs(Real \$a) {
$a < 0 ?? -$a !! $a;
multi sub abs(Real \a) {
a < 0 ?? -a !! a;
}

proto sub truncate(|) {*}
Expand All @@ -129,11 +129,11 @@ multi sub truncate(Cool:D $x) { $x.Numeric.truncate }


proto sub atan2(|) { * }
multi sub atan2(Real \$a, Real \$b = 1e0) { $a.Bridge.atan2($b.Bridge) }
multi sub atan2(Real \a, Real \b = 1e0) { a.Bridge.atan2(b.Bridge) }
# should really be (Cool, Cool), and then (Cool, Real) and (Real, Cool)
# candidates, but since Int both conforms to Cool and Real, we'd get lots
# of ambiguous dispatches. So just go with (Any, Any) for now.
multi sub atan2( \$a, \$b = 1e0) { $a.Numeric.atan2($b.Numeric) }
multi sub atan2( \a, \b = 1e0) { a.Numeric.atan2(b.Numeric) }

proto sub unpolar(|) {*}
multi sub unpolar(Real $mag, Real $angle) { $mag.unpolar($angle) }
44 changes: 22 additions & 22 deletions src/core/Stringy.pm
Expand Up @@ -5,57 +5,57 @@ multi sub infix:<eqv>(Stringy $a, Stringy $b) {
}

proto prefix:<~>(|) { * }
multi prefix:<~>(\$a) { $a.Stringy }
multi prefix:<~>(\a) { a.Stringy }

proto infix:<~>(|) { * }
multi infix:<~>($x = '') { $x.Stringy }
multi infix:<~>(\$a, \$b) { $a.Stringy ~ $b.Stringy }
multi infix:<~>(\a, \b) { a.Stringy ~ b.Stringy }

proto infix:<x>(|) { * }
multi infix:<x>() { fail "No zero-arg meaning for infix:<x>" }
multi infix:<x>($x) { $x.Stringy }
multi infix:<x>($s, $n) { $s.Stringy x $n.Int }

proto infix:<leg>(|) { * }
multi infix:<leg>(\$a, \$b) { $a.Stringy cmp $b.Stringy }
multi infix:<leg>(\a, \b) { a.Stringy cmp b.Stringy }

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

proto infix:<ne>(|) { * }
proto infix:<ne>(|) { * }
multi infix:<ne>($x?) { Bool::True }
multi infix:<ne>(Mu \$a, Mu \$b) { $a !eq $b }
multi infix:<ne>(Mu \a, Mu \b) { a !eq b }

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

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

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

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

proto infix:<~|>(|) { * }
proto infix:<~|>(|) { * }
multi infix:<~|>($x = '') { $x.Stringy }
multi infix:<~|>(\$a, \$b) { $a.Stringy ~| $b.Stringy }
multi infix:<~|>(\a, \b) { a.Stringy ~| b.Stringy }

proto infix:<~^>(|) { * }
proto infix:<~^>(|) { * }
multi infix:<~^>($x = '') { $x.Stringy }
multi infix:<~^>(\$a, \$b) { $a.Stringy ~^ $b.Stringy }
multi infix:<~^>(\a, \b) { a.Stringy ~^ b.Stringy }

proto infix:<~&>(|) { * }
proto infix:<~&>(|) { * }
multi infix:<~&>() { fail "No zero-arg meaning for infix:<~&>" }
multi infix:<~&>($x) { $x.Stringy }
multi infix:<~&>(\$a, \$b) { $a.Stringy ~& $b.Stringy }
multi infix:<~&>(\a, \b) { a.Stringy ~& b.Stringy }

proto prefix:<~^>(|) { * }
multi prefix:<~^>(\$a) { ~^ $a.Stringy }
multi prefix:<~^>(\a) { ~^ a.Stringy }

0 comments on commit 221379e

Please sign in to comment.