I could use some help to work out if overloading math operators can be made to work with mixin via does
(or but
) in a way that avoids the ambiguity error below... this module:
unit module Physics::Error;
role Error is export {
has Real $.abs-error;
method negate {
...
}
}
multi prefix:<-> ( Error:D $right) is export {
...
}
used like by this script...
use Physics::Error;
my $x = 12.5 does Error(0.5);
my $z = -$x;
Ambiguous call to 'prefix:<->(Rat+{Physics::Error::Error})'; these signatures all match: (Rat:D \a) (Physics::Error::Error:D $right)
I want my custom operator to always win unambiguously, then for it to implement the core operation and the Error calcs and then return a (Rat+{Physics::Error::Error}).
Big picture is to do math operations that also perform simple error calculations.
is default
on your multi would help? docs.raku.org/type/Routine#index-entry-is_default_(Routine)is default
to the prefix-
op declaration in your module to just force Raku to always view your module's declaration of the op as the default in the event of ambiguity). Is that what you want? Heh. Hi Liz. Snap. :)is default
does the job --- thank you both (PS OP edited to be clearer on the objective)