Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to Is it time for 'use stricter'? by xdg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-26 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found