Subject: | Consider allowing more easy overriding of overloaded operations. |
Currently the overloaded operators are hardwired to use subroutines in Math::Vector::Real. Classes which inherit from Math::Vector::Real must explicitly overload operators to override them. For example,
package VR {
use base 'Math::Vector::Real';
sub mul { print "FOO\n" }
}
VR->new * 3
calls Math::Vector::Real::mul, not VR::mul. One is forced to do this:
package VR {
use base 'Math::Vector::Real';
use overload '*' => 'mul';
sub mul { print "FOO\n" }
}
The following change to version 0.10 would permit subclasses to more transparently override things:
diff -r Math-Vector-Real-0.10.orig/lib/Math/Vector/Real.pm Math-Vector-Real-0.10/lib/Math/Vector/Real.pm
34c34
< $ol{$op{$_}} = \&{${Math::Vector::Real::}{$_}} for keys %op;
---
Show quoted text
> $ol{$op{$_}} = $_ for keys %op;
Thanks,
Diab