lua-users home
lua-l archive

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


On Tue, Oct 5, 2010 at 1:56 PM, Thijs Koerselman
<thijskoerselman@gmail.com> wrote:
> local require, print = require, print
> module 'mymodule'
> require 'string'
> print(string.format('%s', 'some string'))

After your call to module(), the environment of the chunk has changed,
and require 'string' isn't clever enough to bring the name 'string'
into the module environment. You would have to say 'local string =
require 'string'' at this point.

This is the kind of weirdness that has led to Lua 5.2 dropping
module() altogether - too much messing around with function
environments!

steve d.