http://qs321.pair.com?node_id=630483

Hello, fellow monks:

After reading another node in which the first response informs OP of the value of:

use strict; use warnings;

I had a thought for a modification for the next version of perl--specifically to run automagically with strictures and warnings enabled. Obviously, you'll want the ability to override it for certain things, so we could have a command-line switch to turn it off. This way, we'd still be able to see when people aren't using strict and warn, and lazy people will have less opportunity to skip that step. Of course there are drawbacks: We won't have as many responses to SOPW postings.... ;^) Another is that it would make many programs suddenly break or print gadzillions of unexpected messages.

I've used Super Search to try to learn from previous discussions, but <voice genre="Bad kung-fu move" character="Martial Arts Master">My Script-fu is very bad. I must train for 10 years.</voice> So I likely haven't found the best discussion on the topic.

...roboticus

off to the woods to punch trees for 10 years.

UPDATE: Added 'another' downside that I didn't think of in the first pass. (Much worse downside than I expected.) Thanks, Mutant!

Replies are listed 'Best First'.
Re: RFC: Suggestion for future version of perl
by Corion (Patriarch) on Aug 03, 2007 at 11:23 UTC

    You can have the power of the tools of tomorrow today already:

    export PERL5OPT=-Mstrict -w

    will make your Perl run automatically with use strict; use warnings; enabled and will even use the use warnings; equivalent if the warnings pragma isn't in your Perl already (see perlrun). For maximum effect, put that line into /etc/profile or wherever your users' environment gets set up.

    ~ $ PERL5OPT="-Mstrict -w" perl -e 'print $y' Global symbol "$y" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors.

    If you want to disable the effect, use no strict; or no warnings; in your scripts or oneliners respectively.

      The -X switch is also sufficient to override use warnings; or -w. Note that it works globally, either in scope or warning granularity, unlike the very flexible no warnings;. I wonder that the equivalent switch for strict doesn't exist.

      Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

      That's fine if you own the code base, but I think the idea is to prevent newbies making the classic mistake time and again.
Re: RFC: Suggestion for future version of perl
by Mutant (Priest) on Aug 03, 2007 at 11:24 UTC

    There have been a few discussions on this topic before, and some of them tend to turn a bit nasty :)

    You see, there are a lot of people who like the "quick and dirty" nature of Perl. They don't want strictures on by default, because it will add an extra line to their code. I can understand this for one liners from the command line, but having strictures on by default would not really inconvenience too many people, and the benefits would far outweigh the positives.

    In any case, it wouldn't be a good idea to add this into Perl 5, because it would break too much legacy code. However, Perl 6 - AFAIK - has strictures on by default (not sure about warnings, but I don't see any real reason why this wouldn't be a good idea too).

Re: RFC: Suggestion for future version of perl
by moritz (Cardinal) on Aug 03, 2007 at 12:02 UTC
    Well, the next major version of Perl comes with stricture enabled by default. (I don't know about warnings, though. But I guess they are enablabed by default as well).

    The 5.x dev track has to maintain backwards compatibilty (for 99% or all cases, at least), so no way for default use strict;.

    Update: In Perl 6 onliners via perl -e '...' are still non-strict ;-)

Re: RFC: Suggestion for future version of perl
by Steve_p (Priest) on Aug 06, 2007 at 15:54 UTC

    As a developer, this would be nice. Unfortunately, this would break existing Perl code that is not strict or warnings clean. Actually, this might even break some core tests that rely on the fact that strict and warnings are not enabled.


    Test your modules with bleadperl!

      rsync -avz rsync://public.activestate.com/perl-current/ .
      ./Configure -des -Dusedevel -Dprefix=/path/to/test/perl
      make test
      make install
    

    Now, please test you modules! If you have test failures that don't happen with Perl 5.8.8, send a simplified test case to

    perlbug at perl.org

      And once again we see why Perl 6 had to take a "break everything all at once" approach. Perl 5 was not designed to evolve nearly as well as its author thought at the time... ;)