Skip Menu |

This queue is for tickets about the Math-Vector-Real CPAN distribution.

Report information
The Basics
Id: 88490
Status: rejected
Priority: 0/
Queue: Math-Vector-Real

People
Owner: Nobody in particular
Requestors: djerius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.10
Fixed in: (no value)



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
On Sat Sep 07 22:09:34 2013, DJERIUS wrote: Show quoted text
> 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; > ---
> > $ol{$op{$_}} = $_ for keys %op;
Again, this is not part of the public module API. Redefining some methods from a derived class would not work as the module takes shortcuts internally for performance reasons and just don't use the methods it defines.