lua-users home
lua-l archive

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


Hi,

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"

instead of

    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

    require"socket.http"
    socket.http.request"..."

to

    local http = require"socket.http"
    http.request"..."

?

These modifications would actually remove code from Lua. (Can I see Roberto's
eyes shining?). :)

[]s,
Diego.