lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Diego Nehab wrote:
>> If you call luaopen_socket_core through require, it doesn't matter
>> much if it was in its own dll (socket/core.so) or if it was preloaded
>> in package.preload. In both case it will create the module
>> socket.core. And nothing prevents you from loading socket (ie
>> socket.lua) afterwards. 
> 
> Maybe the problem is that if you require socke.core, it will create a
> the "socket" table, and store a variety of functions there.  If you
> later require"socket" on your own, socket.lua won't be loaded.  The
> "socket" table created by sockt.core will be returned directly
> instead.    

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.

If the socket init function inconditionnaly overwrite the 'socket'
global table things can go wrong. If you used the 'module' function
things should be ok ('module' checks if the table exist and reuse it if
it finds one).