Skip to content

Commit

Permalink
Make infix:<≥> an alias of infix:«>=»
Browse files Browse the repository at this point in the history
By making it an alias, we can get rid of all of the duplication for the
unicode operator.  This reduces memory size (about 10K in the setting.moarvm)
and maintenance burden (because additional candidates will only need to be
added for the ascii version of the operator).

Please note that the alias *must* use <> brackets: apparently creating
constants takes literal names, and 'sub infix:«≥»; normalizes to <> brackets.
  • Loading branch information
lizmat committed Mar 1, 2018
1 parent bc52fef commit a2100ec
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 36 deletions.
3 changes: 0 additions & 3 deletions src/core/Date.pm
Expand Up @@ -205,9 +205,6 @@ multi sub infix:«<»(Date:D $a, Date:D $b) {
multi sub infix>=»(Date:D $a, Date:D $b) {
$a.daycount >= $b.daycount
}
multi sub infix:«≥»(Date:D $a, Date:D $b) {
$a.daycount ≥ $b.daycount
}
multi sub infix>»(Date:D $a, Date:D $b) {
$a.daycount > $b.daycount
}
Expand Down
3 changes: 0 additions & 3 deletions src/core/DateTime.pm
Expand Up @@ -408,9 +408,6 @@ multi sub infix:«<=»(DateTime:D \a, DateTime:D \b) {
multi sub infix>=»(DateTime:D \a, DateTime:D \b) {
a.Instant >= b.Instant
}
multi sub infix:«≥»(DateTime:D \a, DateTime:D \b) {
a.Instant ≥ b.Instant
}
multi sub infix==»(DateTime:D \a, DateTime:D \b) {
a.Instant == b.Instant
}
Expand Down
3 changes: 0 additions & 3 deletions src/core/Instant.pm
Expand Up @@ -87,9 +87,6 @@ multi sub infix:«<=»(Instant:D $a, Instant:D $b) {
multi sub infix>=»(Instant:D $a, Instant:D $b) {
$a.tai >= $b.tai
}
multi sub infix:«≥»(Instant:D $a, Instant:D $b) {
$a.tai ≥ $b.tai
}

multi sub infix:<+>(Instant:D $a, Real:D $b) {
nqp::create(Instant).SET-SELF($a.tai + $b.Rat)
Expand Down
6 changes: 0 additions & 6 deletions src/core/Int.pm
Expand Up @@ -381,12 +381,6 @@ multi sub infix:«>=»(Int:D \a, Int:D \b) {
multi sub infix>=»(int $a, int $b) {
nqp::p6bool(nqp::isge_i($a, $b))
}
multi sub infix:«≥»(Int:D \a, Int:D \b) {
nqp::p6bool(nqp::isge_I(nqp::decont(a), nqp::decont(b)))
}
multi sub infix:«≥»(int $a, int $b) {
nqp::p6bool(nqp::isge_i($a, $b))
}

multi sub infix:<+|>(Int:D \a, Int:D \b) {
nqp::bitor_I(nqp::decont(a), nqp::decont(b), Int)
Expand Down
6 changes: 0 additions & 6 deletions src/core/Num.pm
Expand Up @@ -501,12 +501,6 @@ multi sub infix:«>=»(Num:D \a, Num:D \b --> Bool:D) {
multi sub infix>=»(num $a, num $b --> Bool:D) {
nqp::p6bool(nqp::isge_n($a, $b))
}
multi sub infix:«≥»(Num:D \a, Num:D \b --> Bool:D) {
nqp::p6bool(nqp::isge_n(nqp::unbox_n(a), nqp::unbox_n(b)))
}
multi sub infix:«≥»(num $a, num $b --> Bool:D) {
nqp::p6bool(nqp::isge_n($a, $b))
}

proto sub rand(|) {*}
multi sub rand(--> Num:D) { nqp::p6box_n(nqp::rand_n(1e0)) }
Expand Down
7 changes: 3 additions & 4 deletions src/core/Numeric.pm
Expand Up @@ -303,6 +303,7 @@ my constant &infix:<≅> = &infix:<=~=>;
proto sub infix:<!=>(Mu $?, Mu $?) is pure {*}
multi sub infix:<!=>($?) { Bool::True }
multi sub infix:<!=>(Mu \a, Mu \b) { not a == b }
# U+2260 NOT EQUAL TO
my constant &infix:<> := &infix:<!=>;

proto sub infix<»(Mu $?, Mu $?) is pure {*}
Expand All @@ -322,10 +323,8 @@ multi sub infix:«>»(\a, \b) { a.Real > b.Real }
proto sub infix>=»(Mu $?, Mu $?) is pure {*}
multi sub infix>=»($?) { Bool::True }
multi sub infix>=»(\a, \b) { a.Real >= b.Real }
proto sub infix:«≥» (Mu $?, Mu $?) is pure {*}
multi sub infix:«≥» ($?) { Bool::True }
multi sub infix:«≥» (\a, \b) { a.Real ≥ b.Real }

# U+2265 GREATER-THAN OR EQUAL TO
my constant &infix:<> := &infix:«>=»;

## bitwise operators

Expand Down
9 changes: 0 additions & 9 deletions src/core/Rat.pm
Expand Up @@ -274,15 +274,6 @@ multi sub infix:«>=»(Rational:D \a, Int:D \b) {
multi sub infix>=»(Int:D \a, Rational:D \b) {
a * b.denominator >= b.numerator
}
multi sub infix:«≥»(Rational:D \a, Rational:D \b) {
a.numerator * b.denominator ≥ b.numerator * a.denominator
}
multi sub infix:«≥»(Rational:D \a, Int:D \b) {
a.numerator ≥ b * a.denominator
}
multi sub infix:«≥»(Int:D \a, Rational:D \b) {
a * b.denominator ≥ b.numerator
}

multi sub infix:«<=>»(Rational:D \a, Rational:D \b) {
a.numerator * b.denominator <=> b.numerator * a.denominator
Expand Down
1 change: 0 additions & 1 deletion src/core/Real.pm
Expand Up @@ -157,7 +157,6 @@ multi sub infix:«<=»(Real \a, Real \b) { a.Bridge <= b.Bridge }
multi sub infix>»(Real \a, Real \b) { a.Bridge > b.Bridge }

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

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

Expand Down
1 change: 0 additions & 1 deletion src/core/Version.pm
Expand Up @@ -212,7 +212,6 @@ multi sub infix:«<=» (Version:D \a, Version:D \b) { a cmp b != More }
multi sub infix==» (Version:D \a, Version:D \b) { a cmp b == Same }
multi sub infix!=» (Version:D \a, Version:D \b) { a cmp b != Same }
multi sub infix>=» (Version:D \a, Version:D \b) { a cmp b != Less }
multi sub infix:«≥» (Version:D \a, Version:D \b) { a cmp b != Less }
multi sub infix>» (Version:D \a, Version:D \b) { a cmp b == More }

# vim: ft=perl6 expandtab sw=4

0 comments on commit a2100ec

Please sign in to comment.