lua-users home
lua-l archive

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


> rw20@cornell.edu wrote:
> >Yes, but that's just saying "programmer do XXX  to avoid bugs" and
> >not helping the programmer do it.  Following a global variable naming
> >convention is just as good.
> 
> I don't see what your getting at.
> Please show me how globals and locals can get confused in my scheme.

Sorry, I didn't get the idea that you were suggesting enforcing this 
rule.  There needs to be an option to enforce some variable access model.

Maybe you're proposing that the language change to require all globals be
in this special table and there would be a way to switch between two modes
(say, $global and $globalTable modes).  Then this change is the same as
having a mode that requires globals to follow some naming convention.  I
personally think having an enforcible naming convention is better than
your global.xxx idea since lua could be set up to accept a regular
expression for the global naming (providing the option of making the
global naming convention suit the application).  The use of a local and
global declaration list seems to be the third option (which I like best 
of all). 

So it seems like there are three proposals (since I've finally been
talked out of the method...end (with no local keyword) idea):

1. requiring a global.xxx table access in a new mode, $tableglobals
2. requiring a naming convention in a new mode, $namedglobals
3. using a global access list in a new mode (I've already written this one)

All of these require two Lua modes (so that old code can work) and allow
bug free code from the new mode to work exactly the same in both modes (a
requirement I think).  I think the third one preserves the spirit of Lua
best since it adds a 'global' keyword that functions like 'local'. 

I hope the official Lua team is finding this useful since our discussions 
aren't really important if they aren't interested.

Russ