[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Announce: Darwin module system
- From: David Manura <dm.lua@...>
- Date: Thu, 10 Sep 2009 01:00:36 -0400
On Mon, Sep 7, 2009 at 11:00 AM, Jim Jennings wrote:
> I'll start with an example of the one Darwin function...
> structure.declare { .... }
The documentation for struct.declare defines these code fields:
1. open={m1, ...}
2. pre="..."
3. files=f1 or files={f1, ...}
4. post="..."
5. environment="..."
When first seeing the examples, it was not obvious to me when fields
#2-5 were appropriate and how they interacted. As I see, each of
these represents code and they are executed in sequence. They differ,
perhaps arbitrarily, in that #3 accepts file names, but the others
accept code strings (though you could specify file names in the others
via a dofile or require, as some examples do), and only #5 handles a
return value. Lacking #3, you can arbitrarily choose to place your
code inside #2, #4, or #5. Would something like the following make
the model simpler and more general?
structure.declare {
name="test";
open={"_G", "os"};
environment = [[
pre.....
dofile '.....' .....
post....
return t -- optional (return may be omitted)
]]
}
or using e.g.
environment = {[[pre.....]], '@pre2.lua', '@file1.lua',
[[post....; return t]]}
The typical purpose of #2-4 seems to be to define a module that wraps
another module, whereas the name/signature/location fields define how
that wrapped module is bound into the local namespace tree.