lua-users home
lua-l archive

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


Javier,

Local by default works if there are no globals, only explicitly referred to external vars. In further reading Steve's reference, there are lots of interesting ideas, but if I had to choose, I would use the nonlocal idea for a Python change or the proposal of David Thomas found at the bottom, and specifically for lua. What I don't like about that is that it preserves globals, which just are not necessary. Of course, I am not trying to maintain continuity. I'm trying to come up with a solution that will eliminate a whole class of very difficult to diagnose errors from the language. It also makes recognition absolutely simple. If it does not have a prefix, it is local by definition. If you find an error where you were depending on an external variable, and it does not have a prefix, your problem is solved. I do believe that the prefix should be assigned locally when the variable is imported, again getting rid of a source for conflict that would be created by the use of a default. If you want to allow imported variables to be fulfilled at execution, then you provide a table with an entry that points to an error, only resolved when proper assignment takes place.

Everett L.(Rett) Williams II



Javier Guerra Giraldez wrote:
On Tue, Aug 10, 2010 at 11:57 AM, Everett L Williams II
<rett@classicnet.net> wrote:
  
All declarations would be local by default, not requiring the local keyword,
and things like print(i) would be prefixed.
    
you're forgetting that 'local by default' simply doesn't work with
lexical scoping.  the final result would be something like what David
mentioned