[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: bug in building and installing luasocket
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Thu, 31 May 2007 14:24:22 -0400
Diego Nehab wrote:
>> Unless you manually write something in package.loaded["socket"],
>> require("socket.core") won't, and so any call of the form
>> require("socket") will at least call the init function of socket
>> module (ie. socket.lua). That does not mean that things will be ok,
>> but at least the module system won't get in the way.
> socket.core calls luaL_openlib("socket", func, 0). Won't this create
> a module table and put it in package.loaded["socket"]?
It will, and in that case you cannot load socket after socket.core. That
should be straightforward to fix. You just have register it in
"socket.core", and at the top of socket.lua do something like:
local core = require("socket.core")
for k,v in pairs(core) do
_M[k] = v
I think that shows it's a good habit to use the string passed to the
module init function as the module name instead of a hard coded string.
You never know how people will use (and sometime rename) your modules
(even private submodules as in that case).