2008/5/6 Ricardo SIGNES <perl.p5p@rjbs.manxome.org>: > What if, instead, I could overload method calls on an object? > > package Classless::Root; > use overload method => 'invoke_method'; use overload '->' => \&invoke; # more graphic ? Let's try to think a bit more about this : * that would work only for instance methods, not class methods * that would step over AUTOLOADed methods -- AUTOLOAD would never be called in presence of -> overloading * would that step over regular, existing, defined methods ? If it doesn't, we can instruct invoke() to install new methods, à la AUTOLOAD. * We will need to avoid calling methods on the same object from inside invoke(), to avoid deep recursion. * What if someones invokes the "(->" method directly ? (the internal name of "invoke()".) Maybe all overload methods (whose names begin with "(") should be excluded from this mechanism. * We will probably want a nice way to throw the error "Can't locate object method %s via package %s", like a new builtin, or a core function in the overload package * Of course, subclasses will inherit that overloading. I'm not familiar with the implementation of overloading in the core. That doesn't sound like something really difficult to implement, but don't take my word for it.Thread Previous | Thread Next