|
|
|
|
|
by picomancer
4532 days ago
|
|
If you've ever programmed in JavaScript -- and most people have, it's the language of the Web -- you will know that it is very easy to accidentally omit the "var" keyword and unintentionally pollute the global namespace. Such a bug likely will not manifest until someone else writes completely unrelated code that uses the same variable name by coincidence. Explicit declaration of the scope of a variable at initialization leads to unintended global namespace pollution when omitting the declaration is legal and causes the variable to be placed in the global scope, which can be difficult to diagnose because it is usually completely silent until unrelated code happens to interact by using the same name. From a language design standpoint, this means that you should either require a declaration which determines scope (C or Java), or have local be the default for variables whose scope is undeclared (Python). > I've never heard anyone ever complain about perl's lexical 'my' That's because programmers who care about good syntax in their languages don't use Perl. |
|
Ah, but it's not legal with 'use strict;' (which everyone uses)
> That's because programmers who care about good syntax in their languages don't use Perl.
And Lisp has too many parentheses. I clearly just like my code to be illegible.