You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have found some unexpected behaviour when attempting to redefine the
operator '>'.
First attempt, which works, but redefines 'gt' (however, as this is
defined for string comparisons I would prefer to use '>').
Code is:
multi infix:«gt»( Fpa:D $left, Fpa:D $right --> Bool) is
equiv(&infix:<gt>) { etc etc }
and called by:
my $xx = Fpa.fpaNew();
my $yy = Fpa.fpaNew();
$xx F= '+1133.100000000000000000';
$yy F= '+1133.900000000000000000'; # F+ $testValue;
say $xx.WHAT;
say $yy.WHAT;
if $xx gt $yy { say "OK! It is a \c[PENGUIN];" } else { say "It is not
a \c[PENGUIN]"; }
gives result:
perl6-m ./FPArithTest2.pm6
(Fpa)
(Fpa)
It is not a 🐧
So far, as expected.
Now I amend code to use '>' operator:
multi infix:«>»( Fpa:D $left, Fpa:D $right --> Bool) is
equiv(&infix:<gt>) { .... etc etc }
and called by
my $xx = Fpa.fpaNew();
my $yy = Fpa.fpaNew();
$xx F= '+1133.100000000000000000';
$yy F= '+1133.900000000000000000';
say $xx.WHAT;
say $yy.WHAT;
if $xx > $yy { say "OK! It is a \c[PENGUIN];" } else { say "It is not a
\c[PENGUIN]"; }
now gives result:
perl6-m ./FPArithTest2.pm6
(Fpa)
(Fpa)
Cannot resolve caller Real(FPArith:<0.0.1>::EXPORT::DEFAULT::Fpa: );
none of these signatures match:
(Mu:U \v: *%_)
in block <unit> at ./FPArithTest2.pm6 line 15
which I cannot understand as the $xx.WHAT and $yy.WHAT show both are
Fpa type objects, so should match the 'multi infix:«>»( Fpa:D ...,
Fpa:D .. ) definitions in the multi. (Well, that is my intention.)
The difference between the first (working) example and the second is
just the name of the operator.
OK, so now I try to use 'F>' as this may be a more obvious API:
Here is the API:
multi infix:«F>»( Fpa:D $left, Fpa:D $right --> Bool) is
equiv(&infix:<gt>) { ... etc etc }
and the invoking test:
my $xx = Fpa.fpaNew();
my $yy = Fpa.fpaNew();
$xx F= '+1133.100000000000000000';
$yy F= '+1133.900000000000000000';
say $xx.WHAT;
say $yy.WHAT;
if $xx F> $yy { say "OK! It is a \c[PENGUIN];" } else { say "It is not
a \c[PENGUIN]"; }
Which gives result:
perl6-m ./FPArithTest2.pm6
===SORRY!=== Error while compiling
/home/aparker/Documents/FixedPointArithmetic/./FPArithTest2.pm6
Missing block
at /home/aparker/Documents/FixedPointArithmetic/./FPArithTest2.pm6:15
------> if $xx⏏ F> $yy { say "OK! It is a \c[PENGUIN];"
expecting any of:
block or pointy block
infix
infix stopper
Are these results bugs or I am doing some wrong here?
Migrated from rt.perl.org#131742 (status was 'new')
Searchable as RT131742$
The text was updated successfully, but these errors were encountered: