lua-users home
lua-l archive

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


> FWIW, I agree that lua dumps way too much in the global space.  It's a
> bad practice and usually when I bring it up to people, the response
> is. "Hmm, I haven't thought about, you're right we probably shouldn't
> do that"
>

Thing is, it's something that is easy to do in plain Lua.

All my programs start with

        dpl = require "dplutils"

In `dplutils.lua`, I put all the things I happen to like right now.
(Some of the stuff I liked six months ago has been taken out.  If I
don't agree with my previous self, how much more will I disgree with
someone else!)

Most of it consists of local functions that are put into a table which
is returned at the end.

Nothing, absolutely nothing, stops me from doing this at the same time:

        sys = { arg=arg, _VERSION=_VERSION, _G=_G }
        arg, _VERSION , _G = nil

It's a few lines in `dplutils.lua`, kept there as ling as I like it.
It does not make my usual programs any longer.  It does not force
anyone else to do it too.

Sorry to make this point at such length.  It is not a new point.  It
is basically what Luiz says (very much more briefly) to 90% of the
suggestions on this list.

Dirk