lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks for the clarification :)

Any thoughts on the boxing and unboxing of 10,000 elements (say 32 bytes each) into a lua table, and processing them with a lua function?

-Raymond

On Thu, Jan 8, 2009 at 2:51 PM, Sam Roberts <vieuxtech@gmail.com> wrote:
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