[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Concatenating module files...
- From: Duck <duck@...>
- Date: Sat, 21 Jun 2008 18:53:40 +1000 (EST)
Assume I have two modules, banana.lua and mango.lua, implemented in
separate files which I require() separately. Assume that each module
starts with a line like this:
module(...,package.seeall)
If I simply concatenate the two files into, say, fruit.lua, and change the
module() specifiers so they are like this:
module('banana',package.seeall)
-- rest of banana.lua
module('mango'),package.seeall)
--rest of mango.lua
will I get identical results from "require(fruit)" as I used to get
from "require('banana'); require('mango')"?
And if so, is there a way of "escaping" from the most recent call
to module(), for example so that I could concatenate my main program onto
the end of fruit.lua to make a single file with all by require()
dependencies fulfilled inside?
Is it sufficient to prepend:
orig = getfenv(1)
before the first module code and to append:
setfenv(orig)
afterwards?