lua-users home
lua-l archive

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


On Thu, May 12, 2016 at 9:51 PM, Nagaev Boris <bnagaev@gmail.com> wrote:

> By the way, without any globals, how can one use normal globals like "print", "math" etc?

As mentioned by others, you would need to reference them explicitly via _ENV. So, _ENV.print, etc.

> Always declaring them is annoying.

It is already standard practice in Lua to have local references to globals:

local print, random = print, math.random

So you would just have to say

local print, random = _ENV.print, _ENV.math.random

I do not think that is that big a burden, and the benefit - immunity to typos - is huge.

Cheers,
V.