Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Use strict warnings and diagnostics or die

by jonadab (Parson)
on Feb 03, 2003 at 15:14 UTC ( #232265=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: Use strict warnings and diagnostics or die
in thread Use strict warnings and diagnostics or die

That's a much better example. It seems obvious to me, but I can easily see how it might not be obvious to people who don't cringe when they read "recieved". More importantly, warnings will indeed not catch it. Of course, this means typoing the same variable in the same way more than once... so it still seems somewhat unlikely to me. But it's undeniably a possible scenerio.

I should also note that I have always been in favour of using strict in files that get used or included by other files; it was the value of using it in a regular script that I wasn't seeing.

And yes, I have worked with code that spans multiple files and ten thousand plus lines and uses global variables (though not in Perl, and I did not use globals anywhere near exclusively). The trouble I eventually ran into was not because of this, but because the version of the language and compiler that I had been using had limits on how large the program could be, and when I reached those limits I had to try to port it to the newer version, which proved difficult, and I set it on the back burner. I've also worked with Emacs lisp, which does not have lexical scoping as far as I know (in any event, it is not much used) but solves the namespace issue another way (by making variable names longer; the convention is to prefix your names with the name of your package). It is actually important in Emacs lisp that many variables be global, because you specifically want other code to be able to dynamically scope your variables and thus alter your behavior when it calls you. It is impolite to setq another package's variable in most cases (except from .emacs of course), but you let it as a matter of course. (let in lisp is like local in Perl; AFAIK there is no equivalent to my, nor is it missed.) Then there's buffer-local...


Replies are listed 'Best First'.
Re: Re: Use strict warnings and diagnostics or die
by tachyon (Chancellor) on Feb 03, 2003 at 23:55 UTC

    Although the general convention is to use lower_case type varnames in Perl the case sensitivity of varnames can leadToProblems if you are using camel hump notation and have a case inseneitive Windows type background.

    Bugs related to poorly scoped common varnames like $i, $j, $count, $timeout or often $_ can be also very difficult to isolate in my experience unless you are fortunate with the bug report.




      I do have a case-insensitive background (cut my teeth on PC-DOS 3.3), but while the case sensitivity in my ext3 filesystem occasionally bugs me, I have never had any trouble with case-sensitive variable names. Most of the computer languages I have used (with the notable exception of BASIC, which admittedly I did use quite a bit) are case-sensitive, so I naturally think of variables as case-sensitive.

      But your example is good nonetheless. I said that the scenerio seems unlikely to me, but unlikely is not the same as silly (which is what I formerly thought of the idea, having seen numerous flawed examples and no good ones). Other things (such as Taint mode) are higher on my list, but I now intend at some point to teach myself to use strict.

      It's odd, I came into this thread expecting not to have my mind changed, and it (at least partly) was. I went into the discussion about exception-handling expecting to have someone show me what I was missing, and having read the best explanations offered I'm now more sure than ever that I was right about that one.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://232265]
and the leaves swirl about...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2017-01-22 08:45 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (186 votes). Check out past polls.