in reply to Why isn't C<use strict> the default?

One of the major breaks that Perl6 makes is that strict and warnings(?) will be on by default. You can always turn them off with the P6 equivalent of "no strict".

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

  • Comment on Re: Why isn't C<use strict> the default?

Replies are listed 'Best First'.
Re^2: Why isn't C<use strict> the default?
by gothic_mallard (Pilgrim) on Oct 28, 2004 at 07:23 UTC

    Which is one of the things I'm definitely looking forward to when (if!;)) it appears.

    These are lines that get typed in 99% of the stuff I write (unless there's a good reason not to) and if nothing else, hey, it'll save on finger strain.

    I'm still amazed by the amount of people at my current place of work who don't use strict (experienced programmers and not just new hires). It makes life updating their work when clients require it a bit of a 'mare to say the least. If things like strict were default then my life would certainly be easier.

    --- Jay

    All code is untested unless otherwise stated.
    All opinions expressed are my own and are intended as guidance, not gospel; please treat what I say as such and as Abigail said Think for yourself.
    If in doubt ask.

      These are lines that get typed in 99% of the stuff I write (unless there's a good reason not to) and if nothing else, hey, it'll save on finger strain.
      I always use strict for programs that are not of the -e type, and I'm a lazy typist. My solution was to tell my text editor (vim, but you can surely do something similar with others) to read from a template file whenever I try to edit a non-existent file ending on .pl. The template file includes the shebang line, use strict and use warnings. I also have a template file for *.pm with a little bit more stuff.

        Since you mention it, here's a snippet from my .emacs file.

        (add-hook 'cperl-mode-hook '(lambda () (define-skeleton perl-start "skeleton for a perl program" "" "#!/usr/local/bin/perl\nuse strict;\nuse warnings;" ) (local-set-key [(control c) ($)] 'perl-start) ))

        I do a similar thing in my editor also, but the problem is not us that know enough to decide that's what we want, but those that are just starting out and don't.


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
Re^2: Why isn't C<use strict> the default?
by Juerd (Abbot) on Oct 28, 2004 at 09:22 UTC

    One of the major breaks that Perl6 makes is that strict (...) will be on by default.

    Unfortunately, only in modules. The main program is still strictless :(

    This is one of the things where I hope I misinterpreted the Apocalypses.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      There are several things to say about that. First, all Perl 6 programs already "use strict refs" because Perl 6 differentiates ${$hardref} from $::($symref) syntactically.

      Second, all Perl 6 programs already "use strict syms" because there are no barewords in Perl 6.

      That leaves only "use strict vars" which, as has been pointed out, is on by default in modules and classes. So all you have to do to get strictures in the main program is put

      module Main;
      at the top, and you automatically get strictures and warnings. Hey, it's a lot shorter than IDENTIFICATION DIVISION... :-)

      Look, I grew up in California, where we have decent freeways, by and large. A good freeway has to have both fast lanes and slow lanes, and onramps that don't require you to merge until you're ready. Not everyone coming up the onramp into the slow lane has an engine with great acceleration. I drive a 1977 Honda Accord, and I don't particularly appreciate merging into a freeway when someone whose shoesize is larger than their IQ is coming up in the slow lane at 90 mph, usually in an oversized SUV. But most drivers here are polite, and if you come onto the freeway with less-than-ideal velocity or acceleration, they'll move over to let you on.

      Requiring you to say module Main to get strictures is in the same category as moving over a lane to make it easier for someone to get started on Perl 6, I think. I admit it's an arbitrary place to draw the boundary, but all the other places are just as arbitrary.

        An alternative driving analogy.

        Many modern, high performance cars have a "sports mode" button. Until that button is depressed, various electronic "driver aids", like traction control and ABS are engaged by default. These restrict the ability of the novice driver to get himself into deep doo-doo, the village pond, or nearest brick wall.

        They restrict the power of the engine (by changing gear earlier on autos), override the drivers inputs by reducing the pressure applied to brakes when a skid is about to be invoked, or reducing the throttle setting when the wheels are about to spin.

        Many enthusiasts prefer to drive with these modes disabled because (they claim) a competent driver is able to:

        • stop more quickly in emergencies, especially in slippery conditions, by deliberately inducing a controlled skid.
        • utilise deliberately induced wheelspin to advantage, especially when driving quickly.

        Whilst many will question

        • how many of those enthusiasts are really capable of performing either skill 100% of the time.
        • whether anyone should ever be driving at such speeds that they need to use deliberately induced wheelspin to negotiate corners

        I've never once heard or read of an enthusiast that complained about having to "push the button to disable idiot mode". In fact, most of them wish that it required some demonstration of requisite skill on behalf of the driver, before it would accept the command. This in order to stop all the idiots who don't know how to use a powerful car properly, from killing themselves and others, and causing legislation to be brought in that prevents those that do know how, from enjoying that freedom.


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

        In what way will "module Main;" differ from just "use strict;", at the top of a script?

        Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      I think you're correct, Juerd. AFAIK, it's the enclosing package-type declaration, if any, that determines the strictures.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re^2: Why isn't C<use strict> the default?
by Happy-the-monk (Canon) on Oct 28, 2004 at 13:40 UTC

    until then, you could still bribe your unix sysadmins to   alias perl='perl -Mstrict'   globally.

    Anybody can turn it of with   alias/unalias   and it doesn't affect shebangs anyway, so old code will still work, unless calling perl without a path to it.

    Of course, to be really mean, you could put a wrapper around   /usr/bin/perl   too...

    Cheers, Sören