[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: "import"?
- From: Paul Bleisch <pbleisch@...>
- Date: Sun, 1 Oct 2000 12:17:26 -0500
This appears to require 4.0, no? I should have put the extra
requirement that I need this in 3.2.
Paul
> -----Original Message-----
> From: Roberto Ierusalimschy [mailto:roberto@inf.puc-rio.br]
> Sent: Sunday, October 01, 2000 9:15 AM
> To: Multiple recipients of list
> Subject: Re: "import"?
>
>
> Maybe something like
>
> local newenv = {}
> local oldenv = globals()
> local oldtm = gettagmethod(tag(nil), 'getglobal)
> settagmethod(tag(nil), 'getglobal', function (varname)
> return %oldenv[varname]
> end) -- alow new environment to use all variables from old one
> globals(newenv) -- set new environment
> dofile(filename)
> globals(oldenv) -- restore environment
> settagmethod(tag(nil), 'getglobal', oldtm)
> return newenv
>
> -- Roberto
>