Re: require in another enviroment
[
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: 2012年12月26日 14:11:17 +0200
On Wed, Dec 26, 2012 at 1:52 PM, Victor Bombi <sonoro@telefonica.net> wrote:
> Is there any way to avoid polluting _G (which has bad side effects for me)
> by using require"sc.synthdefsc"
You could use exactly the same loadstring/setfenv trick to load
sc.synthdefsc; then the supplied environment will contain your
assignments after execution, safely outside _G.
Of course, using loadstring() directly means that you need the full
path to sc.synthdefsc module. You can get this by doing what require()
does, which is look in the semicolon-separated package.path, and keep
a record of whether it's already loaded.
steve d.