[Israel.pm] OO Perl and Exporter

Offer Kaye offer.kaye at gmail.com
Tue Dec 28 04:34:30 PST 2004


On Tue, 28 Dec 2004 12:37:35 +0200 (IST), Shlomo Yona wrote:
> 
> You're right about instance methods, but what about static
> methods (methods that belong to the class and not to a
> particular instance of it)?
> 

After a bit of searching, I found "perldoc perltooc". You can read
yourself, but the important bit for this discussion is this, I think:
       You should allow access to class attributes through either the class
       name or any object of that class.  If we assume that $an_object is of
       type Some_Class, and the &Some_Class::population_count method accesses
       class attributes, then these two invocations should both be possible,
       and almost certainly equivalent.

           Some_Class->population_count()
           $an_object->population_count()

In other words, continuing your original example, if f properly
written, the user should be able to write both:
My::Module::With::Its::Long::Name::method();
and
$object->method();

Because it shouldn't matter to the user that "method()" is actually a
class method. Bottom line, in Perl, there's really no distinction -
both object and class method are just subroutines.

So getting back to _my_ original question - is there any valid reason
to use Exporter in a pure, OO module?

-- 
Offer Kaye



More information about the Perl mailing list