[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setfenv/getfenv
- From: Dravonk <dravonk@...>
- Date: Tue, 12 Jan 2010 17:48:44 +0100
Daniel Silverstone schrieb:
> So this would be blah = loadin(pathtoscript, envtab) rather than blah =
> loadfile(pathtoscript) setfenv(blah, envtab) ? That seems emminently
> reasonable and pleasant to use.
It would be
file = assert (io.open (path))
source = file:read ("*all")
file:close ()
func = loadin (env, source, "@"..path)
But in order to address the "reuse"-issue again, with loadin() it would
only be easy to reuse the source and compile the function each time again.
Hmm...as a hack I might use string.dump (func), buffer that and reload
it later using loadin ()...it probably would create more overhead than
just using setfenv () on the function but it would still be more
efficient than compiling the source again.
- David