* Ovid <publiustemp-moduleautho...@yahoo.com> [2010-09-10 08:20]:
> >From: Aristotle Pagaltzis <pagalt...@gmx.de>
> >I would write that
> >
> >    my $self =  shift;
> >    my ( $name ) = @_;
> >
> >:-)
> >
> >(To my way of  thinking, the invocant is not a positional
> >argument, so I always pull it out  of @_ with a `shift`,
> >whereas I unpack arguments using list  assignment.)
>
> Why does this matter? Aside from being able to do this a touch
> cleaner:
>
>  sub foo {
>    my $self = shift;
>    my ($name) = @_;
>    $self->SUPER::foo($name); # if you're still using SUPER::
>    ...
>  }

Yes, that’s actually specifically one of the reasons. But the
primary one is the same as any other convention, really, though:
it communicates to skimming reader that this is a method rather
than a function, at a glance. The `my $self = shift;` line is
much more distinct than tucking a $self away on the @_ line
(especially in the rare cases when it is with good reason not
even called $self).

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

Reply via email to