Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

tsee (4409)

  reversethis-{gro.napc} {ta} {relleums}

You can find most of my Open Source Perl software in my CPAN directory [].

Journal of tsee (4409)

Thursday December 27, 2007
12:10 PM

perl 5.12, strict by default

[ #35213 ]

So I did it. I proposed to the perl5-porters that we should enable "use strict" by default for some future code. This may be a little less preposterous than it sounds at first, so please wait with hitting the "reply" button until you read the whole of this.

My proposal basically goes as follows:

  • Add a feature called "strict" to
  • Include that feature into the set of default features which are loaded by "use feature ':5.11'" or even just "use 5.11.0;".
  • Add a special case for the -E switch to perl so strictures aren't enabled by default for one-liners.

I'll include my original rationale here:

Personally, I've always wanted perl to have strictures on by default for my code. I would think that 95% of all code bases which were written in this century and which are of non-negligible size import "strict". I don't use strictures for one-liners, of course, but for anything else it's a must. It seems to me like others have similar views on this. Try posting some code without "use strict" to some newsgroup or forum and ask for help. Make sure not to give out your email address, though.

"use 5.10.0;" already auto-imports and loads the 5.10 specific features.

How about having "use 5.11.0;" (or 5.12.0) automatically import strict along with the 5.10+5.11 feature set? Naturally, the -E switch for one-liners should *not* do that.

This would *not* break backwards compatibility. This would not affect one-liners. This would optimize for the common case: If you write enough code to make importing optional features worthwhile, odds are very high you'd be importing "strict" anyway. The 5% who need to disable strictures again can still add a "no strict;" statement.

strictures-correct code has been best-practice for a long time now. Let's make it the default for *new* code.

Just think of strictures as a feature. It just makes sense.

To my surprise, the proposal has been received with very positive feedback. So I wrote the patch.

With some luck, we'll get strictures by default in 5.12! Flame away!


The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.