lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

David Given said:

Give that your original suggestion was that global-by-default causes
pollution of the global namespace if you forget to declare a variable, I'd
suggest that this approach to local-by-default causes pollution of the local
namespace instead --- which I think is exactly the same problem!

Whenever you define a variable you are polluting *some* namespace and it is
good programming practice to make that the most local space possible.
Global-by-default is much worse on this count because it can stomp on stuff
*already compiled* even parts of the *standard libraries*! Remember that
globals are run-time bound while locals are compile-time, so at least the
code you are breaking with locals is in the same file or chunk.