[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Basic question about modules
- From: Thijs Koerselman <thijskoerselman@...>
- Date: Tue, 5 Oct 2010 14:50:20 +0200
On Tue, Oct 5, 2010 at 2:16 PM, steve donovan <email@example.com>
After your call to module(), the environment of the chunk has changed,
On Tue, Oct 5, 2010 at 1:56 PM, Thijs Koerselman
> local require, print = require, print
> module 'mymodule'
> require 'string'
> print(string.format('%s', 'some string'))
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
Thanks Steve, I get it. I see that both module and setenv are deprecated in 5.2. What is the most basic way to create a module with
- no pollution of global namespace
- no prefix required for methods to call each other inside module.
- no deprecated functions
I only know how to do this with setenv, and I'm not sure how to replace it with _ENV