Jonathan Rockway wrote: > * On Wed, Apr 08 2009, Michael G Schwern wrote: >> # Moose >> sub DOES { >> return $_[0]->meta->does_role($_[1]); >> } >> >> # Class::Trait >> sub DOES { >> return $_[0]->does($_[1]); >> } > > Why is the Perl 5.10 way ALL CAPS, anyway? DOES is not automatically > called by Perl, is it? (Follow-up question: why is isa not ISA?)
I'd guess the thinking was it's less likely to clash with an existing does() method for those 3 programs out there which will freak out if $obj->can("does") suddenly starts being true. I'm psychic. http://groups.google.com/group/perl.perl5.porters/msg/c75227ea651e0c7e isa() is not ISA() because it was added before Perl 5 OO was widespread enough so as to be so paranoid about new UNIVERSAL methods being added. That being around 5.003. Interestingly enough, when UNIVERSAL came in there were a few extra methods, class() and is_instance(). http://perl5.git.perl.org/perl.git/commit/6d4a7be2b18d1674acf2ccc0da715a204e2d1ed0 They were junked for being redundant. Oddly enough, is_instance() would return as Scalar::Util::blessed() except it works on non-objects which was one of the objections to is_instance() and continues to nag us with unblessed refs. http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1997-02/msg00683.html Amusingly, someone proposes this mythical "perl6" thing that might break the "$class = ref $obj" idiom. http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1997-02/msg00691.html -- If you want the truth to stand clear before you, never be for or against. The struggle between "for" and "against" is the mind's worst disease. -- Sent-ts'an