On Wed, Dec 8, 2010 at 12:59 AM, Vincent Pit <perl@profvince.com> wrote: > I'm sure you're already aware that the > > $obj->$method(@args) > > syntax already has two meanings, depending on whether $method is a code > reference or something else (which then gets stringified, either through > stringification overloading or the usual way). It has three modes in fact: code reference, unqualified method name as string, and qualified name (which is looked up using inheritence starting from the package name in the string, with the package of the object ignored). perl -we '{ package X; @X::ISA = "Y"; } { package Y; sub japh { print { $_[0] } "Judt another Perl hacker\n"; } } $m = "X::japh"; STDOUT->$m;' > Also, if you want to define local methods and you can only use method > names, you have to install your methods into the object's class, because > methods are subs and subs are global. The code reference calling mode > allows you to define such local methods but in a lexical way. I still > think it's a big win. You can also use the third mode to have local methods, so this does not alone prove that the code reference is a big win. AmbrusThread Previous | Thread Next