[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua Socket changes
- From: "Juri Munkki" <jm_list@...>
- Date: Fri, 14 Sep 2007 13:19:27 +0300 (EEST)
On Thu, September 13, 2007 2:08 pm, Ketmar Dark wrote:
> i think that the "core" is loaded from the socket.lua, and not vice
> versa. so "core" doesn't know anything about Lua modules. the aim of a
> "core" is to provide the basic OS interface, so all the other things can
> be built in Lua with this interface. at least LuaSocket 2 works this
> so you should load socket.lua (and maybe other things like url.lua,
> ftp.lua, ltn12.lua, etc) manually.
If you are statically linking socket.core and then calling the loading
function before the main socket module is required (loaded), the main
socket.lua module will not be loaded when you later try to require it,
because Lua thinks it has already been loaded (socket.core also creates a
socket module, but with just some of the functionality).
It took me a little while to figure this out in the application I was
doing... Other people working on the same application for another platform
ended up making this mistake twice even though I had explained it to them
in advance (they just forgot my explanation & warning and didn't read my
source code properly).
You can link socket.core statically to your application, but you then need
to add the loader functions to the preload table or add functionality to
the default module loader to handle it (first solution takes a few more
lines of C, second solution takes a few more lines of Lua).
To put it in simple terms: you have to make sure that socket.lua is the
only place where socket.core will be loaded from.