|
HyperHacker wrote:
It seems that Mr. Manura is the only one who has really thought this whole problem through to it's logical end.On 2010-07-09, Matthew Wild <mwild1@gmail.com> wrote:On 9 July 2010 14:18, steve donovan <steve.j.donovan@gmail.com> wrote:On Fri, Jul 9, 2010 at 1:49 PM, Antonio Vieiro <antonio@antonioshome.net> wrote:Excuse my ignorance, but C has no namespaces and there's no problem in building large applications on top of it, right?Very true, but C requires everything to be declared up-front. Lua will automatically declare an unknown variable to be global (global-as-default), so any misspelling will cause a runtime problem since the new variable will have the value 'nil'. (Perhaps it wouldn't be so bad if the initial value was something like 'undefined').In my opinion, it would. I really dislike the distinction between "nothing" and "nothing" in _javascript_.It's a question of scale. A 100-line script does not have to worry too much about locals and globals, but a 100Kloc program has to be more careful, especially with global-as-default.I think I wouldn't mind a 'global' keyword which imports selected variables from the global environment, similar to (shudder) PHP. MatthewI've always thought PHP's method was somewhat backward. It can be confusing for newbies, and I'm always forgetting to add global imports as I use them. (That, and do we really want Lua to be known as "the PHP of embedded languages"? *shudder*) "This mess, and numerous ways to shoot yourself in the foot, suggests rewriting everything above without environments/globals but rather a straightforward lexical scoping solution that "just works". In addition to a number of messes that he referred to earlier in his post, we had people who wanted to do things by line numbers (back to the original BASIC), people who wanted to use various explicit searches to build tables that then had to be edited and that didn't work in all cases, and etc...ugh. There were those who compared the problems with global by default to those of local by default. Problems with a local variable, in the absence of globals, can be found within the bounds of a contiguous piece of code, where globals cause one to search through every global in every piece of code related to the current one by one of a dozen techniques. This is madness. Such a search may generate a list of globals, one or none of which may actually be related to the problem being experienced. People have a habit of having various standard libraries around, whether they are actually using them or not. It makes sense to do so, as it is a pain to have to bring a library into referenceable scope only when you intend to use it at that particular moment. If external variables only become available in a particular piece of code by explicit reference or inclusion, even if that reference or inclusion drags with it a whole set of variables, then there can be no confusion as to the current scope of a variable or to what it refers. If all this language is to be used for is short macros or interactive code, then it really does not matter what is done, but if it is to be useable for major development projects, it needs to be cleanly constructed. I am not sure that something like lua can be fully statically analyzed, but the rule structure for variable reference can certainly be made much simpler and more likely to yield to simpler analysis than is now necessary. Everett L.(Rett) Williams II |