[tpm] private method call nuances
Alex Beamish
talexb at gmail.com
Mon Jul 20 18:26:16 PDT 2009
On Mon, Jul 20, 2009 at 7:57 PM, Madison Kelly<linux at alteeve.com> wrote:
> Hi all,
>
> I was wondering what, if anything, would be different between calling a
> module's (private) method in these two ways:
>
> $self->_count_module();
> - vs -
> &_count_module($self);
>
> Of course, '$self' is a (hash) reference 'bless'ed into the current module.
> Functionally I don't see a difference (yet).
Functionally, I don't see a difference either, but I have to admit I
squirm whenever I see & in front of a function/method call.
Unless you're calling a reference to a sub, it's unnecessary (and
possibly mis-leading, because @_ is used as parameters if a function
is called with & and no parameters).
Second, calling a method by passing $self in as the first parameter is
correct, but not OO-Perlish. The method _count_module is a method
(albeit a private one), and so should be called in an OO way.
--
Alex Beamish
Toronto, Ontario
aka talexb
More information about the toronto-pm
mailing list