[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: luasocket: luaopen_socket or luaopen_lsocket?
- From: William Trenker <wtrenker@...>
- Date: Mon, 30 May 2005 16:22:04 -0400
(I hope it's ok to ask luasocket questions here.)
I'm using luasocket-2.0-beta3. I've got it running fine with the lua
command-line interpreter and now I'm trying to use luasocket as a
dynamic library, loadable at run time from C code that runs lua
chunks.
I see that the file luasocket.h has the following prototype:
LUASOCKET_API int luaopen_socket(lua_State *L);
but luasocket.c has the function defined as:
LUASOCKET_API int luaopen_lsocket(lua_State *L) {...}
I also see in luasocket.c that luaopen_lsocket calls base_open which
sets the module name as "socket", like this:
luaL_module(L, "socket", func, 0);
As well, socket.lua defines itself as a module with the name "socket", ie:
<...>
local socket = require("lsocket")
module("socket")
<...>
So my question is: Which one is correct: luaopen_socket or
luaopen_lsocket? (It appears, from socket.lua that it is intended to
be luaopen_lsocket. But if that is the case, then should luasocket.c
not be setting its module name to "lsocket", ie,
'luaL_module(L, "lsocket", func, 0);'? As you see, I'm getting myself
confused.)
The files mime.h and mime.c follow the same pattern: mime.h has:
MIME_API int luaopen_mime(lua_State *L);
whereas mime.c has:
MIME_API int luaopen_lmime(lua_State *L) {
...
luaL_module(L, "mime", func, 0);
...
}
Thanks in advance,
Bill