lua-users home
lua-l archive

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


On Oct 3, 2014, at 12:07 PM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:

>> I wonder if there is a plausible luac-wrapper useful for scanning for global variable/references to out-of-scope _ENV members.
> 
> I don't know what you mean by "out-of-scope _ENV members", but see
> 	http://lua-users.org/lists/lua-l/2012-12/msg00397.html

(globals52 is an update of http://lua-users.org/lists/lua-l/2006-05/msg00306.html, but see http://lua-users.org/lists/lua-l/2004-03/msg00223.html, and I think I once found packages predating our tools. The basic technique keeps on being rediscovered independently...)

In Lua 5.2, it is not so clear what a global is, especially in "with"/"using" idioms:

do
  local _ENV = using(_ENV, avcodec.consts, avcodec_alloc_context3(my_codec) )
  bit_rate = 256*1024
  width = 640
  flag2 = FLAG2_FAST
end

This imports the constants in avcodec.consts, and emulates a Pascal "with record" statement: all the record members are placed first in the lookup list.

Sure, you can do this in 5.1, but in 5.2, it's crystal-clear what's going on. It also breaks the tiny little mind of lualint.

Jay