lua-users home
lua-l archive

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


On Jul 11, 2010, at 5:06 PM, Jonathan Castello wrote:

> What if no syntax was changed, but every chunk got its own personal
> environment instead, which library functions like require() can import
> into the calling chunk's environment if desired? You could have one
> function that maintains the current behavior (which would probably
> remain require()), and another that simply returns the chunk's
> environment.

You can already get that in 5.2 with loadin (or 5.1 with a setfenv after the load).

The more I think about this, the more I think that the language probably doesn't need changing. What's needed are more and better semantic analysis tools. (The downside to the 5.2work3 changes is that there are no longer SETGLOBAL and GETGLOBAL instructions that a bytecode analyzer can look for so the task of looking for global accesses if one doesn't want them becomes a bit harder.)

It might be nice to increase the set of characters allowed in variable names and/or sort out token filters so that if one wanted to do something like make all globals be named with a $ at the front of their name, one could. But that would be an individual choice with respect to Lua usage.

Mark