Skip Menu |
Queue is disabled
This queue is disabled and you may not create new tickets in it. Disabled queues are usually because the distribution was merged with another or changed names. Sometimes they are the end result of a bad autocreate from PAUSE data before anyone noticed.
Report information
Id: 131742
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: andynparker [at] googlemail.com
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Date: Wed, 12 Jul 2017 12:41:47 +0100
From: Andrew Parker <andynparker [...] googlemail.com>
To: "rakudobug [...] perl.org" <rakudobug [...] perl.org>
Subject: [BUG] - Redefining operator '>'.
Download (untitled) / with headers
text/plain 2.4k
Hi, 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? Regards, Andrew N Parker


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org