Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
remove abs as a prefix op, make it a normal sub instead
  • Loading branch information
moritz committed Jul 21, 2012
1 parent 81328c3 commit 5b56cfc
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/Perl6/Grammar.pm
Expand Up @@ -2596,7 +2596,6 @@ grammar Perl6::Grammar is HLL::Grammar {
token infix:sym<|> { <sym> <O('%junctive_or')> }
token infix:sym<^> { <sym> <O('%junctive_or')> }

token prefix:sym<abs> { <sym> » <O('%named_unary')> }
token prefix:sym<let> { <sym> \s+ <!before '=>'> <O('%named_unary')> { $*W.give_cur_block_let($/) } }
token prefix:sym<temp> { <sym> \s+ <!before '=>'> <O('%named_unary')> { $*W.give_cur_block_temp($/) } }

Expand Down
2 changes: 1 addition & 1 deletion src/core/Complex.pm
Expand Up @@ -203,7 +203,7 @@ multi sub prefix:<->(Complex:D \$a) returns Complex:D {
$new;
}

multi sub prefix:<abs>(Complex:D \$a) returns Num:D {
multi sub abs(Complex:D \$a) returns Num:D {
my num $re = nqp::getattr_n(nqp::p6decont($a), Complex, '$!re');
my num $im = nqp::getattr_n(nqp::p6decont($a), Complex, '$!im');
nqp::p6box_n(nqp::sqrt_n(nqp::add_n(nqp::mul_n($re, $re), nqp::mul_n($im, $im))));
Expand Down
4 changes: 2 additions & 2 deletions src/core/Int.pm
Expand Up @@ -83,10 +83,10 @@ multi prefix:<->(int $a) returns int {
nqp::neg_i($a)
}

multi prefix:<abs>(Int:D \$a) returns Int:D {
multi abs(Int:D \$a) returns Int:D {
nqp::abs_I(nqp::p6decont($a), Int);
}
multi prefix:<abs>(int $a) returns int {
multi abs(int $a) returns int {
nqp::abs_i($a)
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/Num.pm
Expand Up @@ -249,10 +249,10 @@ multi prefix:<->(num $a) {
nqp::neg_n($a);
}

multi prefix:<abs>(Num:D \$a) {
multi sub abs(Num:D \$a) {
nqp::p6box_n(nqp::abs_n(nqp::unbox_n($a)))
}
multi prefix:<abs>(num $a) {
multi sub abs(num $a) {
nqp::abs_n($a)
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/Numeric.pm
Expand Up @@ -37,8 +37,8 @@ multi prefix:<+>(\$a) { $a.Numeric }
proto prefix:<->(|$) { * }
multi prefix:<->(\$a) { -$a.Numeric }

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

proto sub sign(|$) {*}
multi sub sign(Numeric \$x) { $x.sign }
Expand Down
2 changes: 1 addition & 1 deletion src/core/Real.pm
Expand Up @@ -119,7 +119,7 @@ multi sub infix:<mod>(Real $a, Real $b) {
$a - ($a.Bridge.Int div $b.Bridge.Int) * $b;
}

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

Expand Down

0 comments on commit 5b56cfc

Please sign in to comment.