lua-users home
lua-l archive

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

On Fri, May 13, 2016 at 5:27 PM, Dirk Laurie <> wrote:

> 1. We will need some new syntax.

I am not so sure at this point. Today globals are merely a shorthand for, where _ENV itself is a local. So the entire functionality of globals is available by using _ENV explicitly. By simply disabling the language feature that upgrades "free names" to globals, we address the current shortcomings.

The question remains, how can this be fully backward compatible. First, the code that uses _ENV explicitly is correct even today. So if this new code gets loaded into an older environment, it will still work just fine. Second, we can only select the "no globals" mode when we know for sure the environment supports that. Observe that the above implies that the policy decision need only be made when the code gets loaded. Consequently, Lua's basic load routines (including the C API) should support both modes, and a policy layer can be created that is responsible for choosing an appropriate mode. By default, the "old" mode will be effective.