Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: strict, scope, my and foreach - not behaving as expected

by wolv (Pilgrim)
on Jun 09, 2004 at 13:18 UTC ( [id://362722]=note: print w/replies, xml ) Need Help??


in reply to Re: strict, scope, my and foreach - not behaving as expected
in thread strict, scope, my and foreach - not behaving as expected

Modifying the program is not inherently harmful, and in my opinion, modifying code that does not run under strict is usually a good idea. Not that all programs should be made to run under strict, but the fact is that it prevents a lot of subtle bugs that might not come up in normal debugging at all.

As to the problem in the original question, I'd like to ask 'why' too; why make the iteration variable global? Call-by-value is really not that expensive, and if you feel it is, use $_[0].

Replies are listed 'Best First'.
Re: strict, scope, my and foreach - not behaving as expected
by Abigail-II (Bishop) on Jun 09, 2004 at 14:10 UTC
    Modifying the program is not inherently harmful,
    Not inherently harmful? I'd say a large percentage of bugs in programs comes from the fact someone modified the program. That's my point. If something is not broken, don't fix it.
    but the fact is that it prevents a lot of subtle bugs that might not come up in normal debugging at all.
    It was given that the program was working. I assume that the OP doesn't mean "it has bugs" when he writes "working".

    Adding strictness on a working program is a bit like rebuilding the Egyptian pyramids because originally the construction workers weren't wearing safety harnesses.

    Abigail

      The difference is no one is going to be adding on to the pyramids and even if they did the proper equipment could be used for the additional construction.

      New functionality may need to be added to the existing program, strict can help in that department but you would need it for the entire program. Plus just becase a program works doesn't mean it doesn't have bugs that could be caught by adding strict

      Everyone would be much better off if coders stopped writting code that "works" and instead started writting code that works well, scales, and is easy to maintain. Of course, since we are talking about humans, that's not too likely to happen soon :)

        Yeah, the keyword here being additional construction. The OP wasn't talking about extending a program. He was adding strict for the sake of adding strict.
        New functionality may need to be added to the existing program
        Yes, but why spend time now for something that may not happen? It's not that if a program remains stable for another year, that you have to hit the keyboard harder if you are going to add strict in a year, when you do modify the program.
        strict can help in that department but you would need it for the entire program.
        Sillyness. use strict is lexically scoped.
        Everyone would be much better off if coders stopped writting code that "works" and instead started writting code that works well, scales, and is easy to maintain.
        Totally beside the point. The program has already been written. Besides, just slapping a 'use strict' on the program isn't magical wand. Writing easy to maintain programs that scale well takes a lot more than slapping 'use strict' on the program. In fact, there isn't much relation between them.

        Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://362722]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-19 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found