[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Performance Question
- From: "Sam Roberts" <vieuxtech@...>
- Date: Thu, 8 Jan 2009 11:51:12 -0800
On Thu, Jan 8, 2009 at 11:23 AM, Raymond Jacobs <raymondj@gmail.com> wrote:
> Yeah i am using it for various scripts, so probably not.
>
> Now, what if this script includes functions; I imagine those are added to
> the registry when loadstring is called?
No. loadstring just returns a function that is the compiled code you
loaded. Call it "F".
> it is possible that subsequent loadings could overwrite them; i assume just
> calling the function returned from loadstring wont restore them?
It will.
The functions defined F are created when you run F, not when you
compile F, each time (overwriting any previous definitions).
Well written code would probably not create global functions, it would
use local a lot.
Or to avoid the script writer having to think about this, the use
lua_setfenv() on F to provide it with a "global" table, so it doesn't
pollute the global namespace, and the writer doesn't have to consider
the distinction between local and global.
Sam