lua-users home
lua-l archive

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


The solution to name spaces in general is to get rid of the concept of globals entirely, and make it possible to pass a pointer to the namespace of a chunk or module, requiring that a modifier be used to refer to all such pointed to namespaces. Any variable created in a chunk or module would be local by definition. If a variable is declared as local, then it would not be visible to any other module or chunk. If you wish to use a local copy of a variable from another chunk or module, you would precede the reference with a "l." or even the "$". Now I haven't completely thought this version of the idea out for lua and am not a sufficient expert in lua to do so. Removing ambiguity is the goal and there is far too much ambiguity in functional languages almost by definition. The guy who wrote about doing things for newbies merely wants to leverage his experience at the expense of the growth and usefulness of the language. Some will misuse almost any thing, and some will just ignore something that is biting them on the nose, but everything that can be done to clarify a language should be done. Subtlety is not a virtue unless one is consoling another about something personal. Subtlety in code is hard enough to maintain by the person who wrote it, much less the poor benighted soul who must maintain another person's code.

Everett L.(Rett) Williams II





Vaughan McAlley wrote:
On 9 July 2010 10:03, Vadim Peretokin <vperetokin@gmail.com> wrote:
  
I'm not sure why. In my case, they're great for newbie scripters (who just
want to use the language to accomplish some simple goal with help of
scripting) - their variables work across a variety of inputs/outputs they
can interact with since they're global to the state.

    
Personally I liked being able to use globals before I learned how
lexical scoping worked. They are definitely easier to use for
beginners, which I think is part of why Lua is easy to learn. I would
advise beginners to give their variables unique names of course.

Though if I "pollute the namespace" with a global called "a" or
"count", it’s only 50% my fault :-)

Vaughan