Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix infix:<before>/infix:<after> for Complex
Currently before/after uses `cmp` that's pretty liberal with allowed types,
which makes comparisons like `i after 42` "work". Per TimToady++[^1], these
should use infix:«<=>», which this patch makes it do.

However, one side effect of this is that <42+42i> after <41+42i> used to work,
but now throws, as infix:«<=>» only works with complex if the imaginary part
is negligible compared to the real part. So.... is before/after on two
Complex supposed to use `cmp` instead of `<=>`? I've no idea...

[1] https://irclog.perlgeek.de/perl6/2017-02-02#i_14028605
  • Loading branch information
zoffixznet committed Feb 2, 2017
1 parent 7384939 commit ab3162c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/Numeric.pm
Expand Up @@ -39,6 +39,9 @@ multi sub infix:<eqv>(Numeric:D \a, Numeric:D \b) {

## arithmetic operators

multi sub infix:<before>(Numeric \a, Numeric \b) { (a <=> b) < 0 }
multi sub infix:<after> (Numeric \a, Numeric \b) { (a <=> b) > 0 }

proto sub prefix:<+>($?) is pure { * }
multi sub prefix:<+>(\a) { a.Numeric }

Expand Down

0 comments on commit ab3162c

Please sign in to comment.