-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested sub definitions - compile time warning #14854
Comments
From @epaCreated by @epaYou can nest subroutine definitions, as sub x { sub y {} } Although at first glance it looks like the definition of y is somehow There are uses to making subroutine definitions inside a BLOCK, to { my $x; sub y { ++$x } } but that does not apply if the block is itself a subroutine definition (This would also smooth the path for adding some more useful semantics Perl Info
|
From @rjbs* Ed Avis <perlbug-followup@perl.org> [2015-08-14T08:50:29]
I have seen this mistake more times than seems reasonable, almost always as an I find the suggestion tempting. Part of the issue is that it indicates a I'd also think this error would apply to: sub foo { ...but perhaps there is use for: sub foo { ...or the like. Anyway, I think it's a useful warning. On the other hand, it's also a warning -- |
The RT System itself - Status changed from 'new' to 'open' |
From @AbigailOn Mon, Aug 17, 2015 at 06:40:06PM -0400, Ricardo Signes wrote:
Why not start with a warning in Perlcritic, and if it turns out to catch Abigail |
From @rjbs* Abigail <abigail@abigail.be> [2015-08-18T03:00:18]
It would be really great if we had some way to get feedback on which perlcritic -- |
From @rjbs* Abigail <abigail@abigail.be> [2015-08-18T03:00:18]
It turns out there is one. And that I wrote it, in 2007! https://metacpan.org/pod/Perl::Critic::Policy::Subroutines::ProhibitNestedSubs I'll see what I can find out about who else benefitted from it. Or, possibly, -- |
From @epaPerhaps now that true lexically scoped subroutines exist, there is a case for revisiting 'sub' inside 'sub' and directing the programmer towards 'my sub' instead? |
Migrated from rt.perl.org#125809 (status was 'open')
Searchable as RT125809$
The text was updated successfully, but these errors were encountered: