Stories
Slash Boxes
Comments
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Scoping (Score:2, Informative)

    by bart (450) <bart.lateur@pandora.be> on 2003.10.31 21:06 (#25356) Journal
    I must say, I find it a pretty good article, but I disagree on the author's point of view on variable scoping — in addition, he seems to have overlooked a few extremely bad traps.
    • As opposed to the author, I do like automatic limiting of the scope of variables to the sub (er, "function") they are in. By contrast to perl, everything that you use is a local variable, unless you explicitely say it isn't. I think that's a good thing.
    • OTOH, I hate it that every variable you create outside of a function, is a global variable. There's no way you can lexically limit the scope of a variable to a block or library file. Everything is visible from everywhere.
    • Furthermore, there's no namespaces (no "packages", in Perl terms), so global name clashes are something to be very wary of.
    • And finally: the autoglobal feature can allow the user, through clever use of CGI parameters on the browser's URL, step on any one of them, making the script behave in all sorts of unintended ways, unless the programmer explicitely clears them.
    • The piece does a good job of showing you ways the you can shoot yourself in the foot while using PHP, but I really think many of these problem can be avoided in any professional development context. By "professional development context," I mean you are running your own machine and server and aren't on a shared host. On your own box, you have control over all the settings and can make sure all the troublesome ones are turned off, the good ones are enabled, etc. Whether PHP should allow you to use "stupid" s