Perhaps it's due to the recent release of TheDamian's book, Perl Best Practices, or maybe there's just something in the air, but perlstyle interest seems to be flourishing. Recent examples include Things I Don't Use in Perl, Perl Best Practices for naming variables and Perl Best Practices (review).
Maybe its time for style to be more than just a recommendation. Inspired by the recent, lengthy debate on the module-authors list about RFC: Test::Stupid, I'm wondering if it's time for a new pragma: 'stricter'.
stricter would use source filtering to check not just for the usual 'vars', 'refs' and 'subs', but for style no-no's as well. Examples of individual options might include:
use stricter 'names'; # no names in MixedCaps use stricter 'features'; # no ties, lvalue subs or pseudohashes use stricter 'accessors'; # no accessors that are also mutators use stricter 'open' # 3-argument open only use stricter 'syntax'; # no 'until' or 'unless' or c-style 'for' lo +ops use stricter 'whitespace' # no tabs, only spaces use stricter 'layout'; # must match a perltidy format
As with strict, failure of any code following 'use stricter' to meet the style requirements would cause compilation to fail with an appropriate error message and a pointer to the offending line. Of course, any of these could be turned off within a particular block with an appropriate 'no stricter' line.
It is important that stricter should be easy to subclass to customize style restrictions for particular flavors or projects, e.g. 'use stricter::pbp'. This feature would allow teams of Perl programmers to easily standardize and check their coding practices by simply customizing and adding an appropriate stricter to their modules and scripts.
I think this would be a valuable addition to the Perl pragma family. Don't you?
(If you've read this far and haven't figure out that I mean this in jest, please take a deep breath and walk around in the fresh air a bit -- you're entirely too wound up. Sometimes we need to not take ourselves too seriously.)
Regards,-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Is it time for 'use stricter'?
by holli (Abbot) on Aug 24, 2005 at 16:22 UTC | |
Re: Is it time for 'use stricter'?
by ysth (Canon) on Aug 24, 2005 at 15:31 UTC | |
Re: Is it time for 'use stricter'?
by QM (Parson) on Aug 24, 2005 at 16:06 UTC | |
Re: Is it time for 'use stricter'?
by diotalevi (Canon) on Aug 24, 2005 at 17:31 UTC | |
Re: Is it time for 'use stricter'?
by bluto (Curate) on Aug 24, 2005 at 16:43 UTC | |
by chester (Hermit) on Aug 24, 2005 at 16:52 UTC | |
Re: Is it time for 'use stricter'?
by brian_d_foy (Abbot) on Aug 25, 2005 at 05:31 UTC | |
Re: Is it time for 'use stricter'?
by perrin (Chancellor) on Aug 24, 2005 at 19:27 UTC | |
by Tanktalus (Canon) on Aug 24, 2005 at 22:05 UTC | |
by cchampion (Curate) on Aug 24, 2005 at 23:14 UTC | |
Re: Is it time for 'use stricter'?
by leriksen (Curate) on Aug 25, 2005 at 00:43 UTC | |
Re: Is it time for 'use stricter'?
by zby (Vicar) on Aug 25, 2005 at 07:04 UTC | |
by xdg (Monsignor) on Aug 25, 2005 at 10:36 UTC | |
by jthalhammer (Friar) on Jan 13, 2006 at 07:02 UTC | |
Re: Is it time for 'use stricter'?
by nothingmuch (Priest) on Aug 27, 2005 at 02:12 UTC | |
Re: Is it time for 'use stricter'?
by Anonymous Monk on Jan 13, 2006 at 16:07 UTC | |
Re: Is it time for 'use stricter'?
by Anonymous Monk on Aug 25, 2005 at 19:31 UTC | |
Re: Is it time for 'use stricter'?
by pileofrogs (Priest) on Jan 14, 2006 at 18:43 UTC |