[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Packaging and importing
- From: Diego Nehab <diego@...>
- Date: Mon, 15 Aug 2005 16:30:36 -0400 (EDT)
I guess you can fix the two problems without the downside by making
"module" do not inherit globals into the new environment.
I wouldn't mind at all. In fact, I prefer it. It has become common
practice for a package to require() everything it needs into local
variables *before* it invokes module() anyways. There is no need for
globals to be accessed through the namespace. I actually remove the
metatable from it as soon as I call module().
I would also prefer if module() didn't register the namespace into the
globals table. The least collateral effects, the best. I don't think it
would solve Mark's problem, though. People would still write
socket = require"socket"
local socket = require"socket"
Omiting the "local" would actually be useful when running the
command line interpreter, as Mark also points out.
For modules with submodules, it is uncommon to use the nested
namespaces. Who would prefer
local http = require"socket.http"
These modifications would actually remove code from Lua. (Can I see Roberto's
eyes shining?). :)