[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Coding 5.1-style packages to allow static linking of C code..
- From: David Burgess <dburgess@...>
- Date: Mon, 10 Jan 2005 23:45:17 +1000
> Just took a bit of time to look at compat-5.1.lua, and at the
> the thread from September 2004 where the package stuff came from.
> Now, consider a hybrid C/Lua pacakge in which you require() Lua code which
> itself require()s a C library (e.g. luasocket). Do I understand correctly
> that if you statically link the C library, then you must register its
> initialisation function in the table package.preload at startup time, so
> that require() will behave correctly?
Do not forget that luaL_openlib() adds the package to package.loaded
> If I've got this correct, my next question is this: is there a proposed
> standard way (or a standard luaL_helper() function) to take care of the
> preload case?
So modify lua_userinit(L) and you are away.
> Indeed, is there a propsed standard way for hybrid C/Lua packages to have
> their Lua code "statically linked" and tidily called from the library
> initialisation code in the standard Lua interpreter?
lua_userinit(L) would have to be it.