[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: More about packaging (hopefully not too long)
- From: RLake@...
- Date: Tue, 8 Jun 2004 10:04:22 -0400
> I'll comment on Rici's post here. It seems like
an unnecessary complication to
> require that Lua code be embedded in a library in order to create
I agree. It shouldn't be a requirement for the system
to work. However, it
is a possibility and I think it is much cleaner for
a production distribution,
particularly for those of us who like to deploy single
The advantage of "require" working identically
with either Lua or foreign
libraries is that both modes are possible without
editing user programs.
Similarly, requiring Lua stubs to exist for every
C library also seems
to me an unnecessary complication, both for users
and for packagers.
> Actually, I've just convinced myself that the
> should not exist at all.
By the way, although I agree that "import"
is not something I would use,
I gave a one-liner for it:
function import(name) _G[name] = require(name)
so anyone who wanted that behaviour could easily get
it. It is worth
thinking about the complexities introduced by setfenv(),
replacing _G with getfenv() in the above would mean
that the module
was imported into import()'s environment table, quite
what was expected. It is for this reason, amongst
others, that I
think "automatic globals" are a bad idea.
PD: Path searching is a pain. However, it has proven
its value over
the years and alternative systems rarely work as well.
number of people who have been caught out by ldconfig,
Caches are notoriously difficult to get right. Built-in
paths seem to
be difficult to document (and therefore for non-sophisticated
Having said that, the sample code I provided yesterday,
module instantiation functions as an intermediate
is a surprisingly powerful model. It allows the detailed
procedure to be abstracted into an single function;
not need to know where the mod.inst.func comes from,
it just needs
to run it.
The actual code I use for sandboxing takes advantage
of this; setting
up a table of instantiation functions for a sandbox
is simpler than
coming up with an OS-independent way of checking the
file paths. In addition, it makes it easier to do
things like load
modules over networks, or from comressed archives,
The fact that Lua deals so cleanly with functional
objects and closures
provides possibilities which should not be overlooked