[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: require in another enviroment
- From: steve donovan <steve.j.donovan@...>
- Date: Wed, 26 Dec 2012 21:41:20 +0200
On Wed, Dec 26, 2012 at 3:19 PM, Victor Bombi <sonoro@telefonica.net> wrote:
> ---------------sc,synthdef.lua
> variable = 1234
> require"blabla"
> more_things
Yes, require() is not going to work as you want it to. But it would be
possible to rewrite it so that it sets the environment of the blabla
module to be the environment of the caller. It would (1) use
getfenv(2) to find out caller env (2) find the module using
package.path & load the file (3) set the module chunk env and execute
it and (4) keep track of its loaded status.
steve d.