[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why does luaL_openlibs invoke the interpreter?
- From: Steven Johnson <steve@...>
- Date: Sat, 7 Feb 2009 22:33:07 -0600
> There may be another reason, but that's the first that comes to mind.
>
For another reason, look into luaopen_io (and then the rest of the library,
I guess). Once the function is in Lua you can alter its environment. This
makes it easy to load a lot of functions and objects with shared state.
http://lua-users.org/lists/lua-l/2005-04/msg00129.html
Also, like the point about the stack, you're spared some cleanup effort,
since you don't have to save and restore the original environment.