lua-users home
lua-l archive

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


On Fri, Jul 9, 2010 at 12:16 AM, Henk Boom <henk@henk.ca> wrote:
IMO explicit declarations are a good thing because they clarify
scopes. I would love for all variables would be statically and
lexically scoped, so that the compiler could generate compile-time
error messages for undeclared variables. That requires that you be
able to statically determine module imports, though. (maybe it could
be done with metalua)


Not reliably: since require() is a regular function call on a regular global var, it can be constructed in arbitrarily complex ways:

add_r = |x| 'r' .. x
getfenv()[add_r 'equire'] 'imported_module'

But rebuilding a dependency graph based on occurrences of global 'require' is not difficult, and has already been done, including in at least one commercial product.

-- Fabien.