On Wed Sep 13 12:05:05 2006, chromatic@wgz.org wrote: > On Wednesday 13 September 2006 09:33, Joshua b.Jore wrote: > > > overload::Overloaded depends on the overloaded object's class's > > implementation of ->can returning true for the method (). ->can is > > part of the class implementation and might not know that () is a > > special case to be handled. In my code I had a ->can() that always > > returned false because I had an object with no valid methods. > > Your can() is broken. I don't understand why you expect any other > code to > work with it. > > By way of analogy, how should external code cope with: > > sub new {} > ? > > At least your can() should call SUPER::can() to respond affirmatively > for the > methods valid on *any Perl object* such as can(), isa(), and > VERSION(). But the whole purpose of overriding ->can is to make it work with AUTOLOAD. Overloading does not respect AUTOLOAD, and therefore overload methods are not your regular methods. So calling ->can for overload methods is almost always wrong. An overridden ->can could return true, because it delegates all unknown methods to some other object (and its own can returns SUPER::can{@_} || $that_object->can($_[1])). That’s perfectly reasonable, but overload::Overloaded’s current implementation cannot handle it. -- Father Chrysostomos --- via perlbug: queue: perl5 status: open https://rt.perl.org:443/rt3/Ticket/Display.html?id=40333Thread Next