We can then do:my $err = Example::Error->new('Heat death of universe detected!'); $err->My::AwesomeError::asplode(); $err->Your::GroovyError::asplode(); $err->asplode(); # Russian roulette
Of course you can, but it's not really a benefit. As you wrote in the OP, monkey patching is often done to work around limitations in existing code that you don't want to patch. But writing $obj->Class::method() requires the author of that code to be aware of the issue, and when he is, he can simply write Class::method($obj) without requiring any monkey patching.
I do find your idea cute, but it really doesn't solve the "hard" problem, and the small problems it does solve seem to be either artifically constructed, or non-issues.
In reply to Re^3: Safer monkey-patching
by moritz
in thread Safer monkey-patching
by tobyink
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |