On Sat Jul 12 15:02:20 2008, jeff@imaginative-software.com wrote:
Show quoted text> On Sat, Jul 12, 2008 at 11:48 AM, Chris Dolan via RT <
> bug-Perl-Critic@rt.cpan.org> wrote:
>
> > Queue: Perl-Critic
> > Ticket <URL:
http://rt.cpan.org/Ticket/Display.html?id=37632 >
> >
> > Hmm, I'm surprised that's legal at all. We should make a policy to
> > forbid subroutines named "sub" or "package" or "use", etc.
> > Chris
> >
>
> At the moment, Subroutines::ProhibitBuiltinHomonyms only covers user
> functions that have the same name as a builtin function. But we could
> easily extend that to include user functions that have the same name as a
> perl keyword. Or do you think that should be a separate Policy?
>
> -Jeff
To me, a user function hiding a Perl builtin function and thus
introducing context-dependency should be rated with a higher severity
than a method name with a namesake in a completely different syntactical
domain. In Perl, method calls are always qualified with a class or
variable name and thus easily distinguishable from everything else, so
that naming policies might want to allow more freedom for methods than
for, say, plain subroutines.
To support this, Perl::Critic would need to tell methods from plain
subroutines, which unfortunately is not always easy. A good guess might
take into account whether the name is exported and how it is used locally.
In conclusion, I'd prefer a separate policy. Either way, PPI should of
course correctly parse method calls.
-Martin