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
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
JS 1.7 Java? (Score:2)
JavaScript 1.7 has block scoped variables. I'm not sure what browsers besides FF 2 and newer support it though.
Re: (Score:2)
Re: (Score:2)
(function () { var iHaveMyOwnScope = '...' })().Re:JS 1.7 Java? (Score:2)
You're talking about Java and not Javascript? (Score:2)
Now in JavaScript, the rules are different, but I presume you're smart enough not to say "Java" when you mean "JavaScript".
Re: (Score:2)
Considering he does Java programming most of the time now, I doubt he'd mistakenly call JavaScript Java.
I haven't written any Java since about 1998 and I try not to read it too often as it usually makes my head hurt. ;)
But if I'm reading this right, it looks like the for loop would need to be enclosed inside another block for it to work like J. David is expecting...
Re: (Score:2)
Apparently my example has confused nearly everyone I've asked about this. Yes, I meant Java. The for loop actually has nothing to do with it. Let me say it in Perl, and drop the for:
Of course, you can argue all day that declaring a variable in an inner block that shadows a variable in an outer block like this is a bad idea. It probably is. :) But the question for me is: did Java designe
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
Feature (Score:1)
Reusing a variable name in the same method is a TERRIBLE idea and is a beartrap waiting for some future maintenance programmer. Why would you want to do that?
This sounds like a great opportunity for a Perl::Critic policy.
Re: (Score:1)
OK, done. There is now a P::C policy for this:
http://perlcritic.tigris.org/source/browse/perlcritic/trunk/Perl-Critic/lib/Perl /Critic/Policy/Variables/ProhibitReusedVarNames.pm [tigris.org]
Comments welcome.
Re: (Score:2)
Comments welcome.
How does "++" grab you? :)