lua-users home
lua-l archive

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

Paul Ducklin wrote:
> This isn't any kind of bug :-) But I thought of it as a result of
> this thread. 
> What if LuaSocket were divided so that instead of being modulised
> with two shared libs in subdirectories, it consisted of two core C
> packages plus the various Lua components?  
> socket.core and mime.core are terribly useful on their own, so if
> they were implemented as (say) coresock and coremime, and were
> require()d accordingly from socket.lua and mime.lua, they could very
> much more easily be built and used on their own.   
> In particular, it would then be trivial to build a Lua binary with
> coresock and coremime compiled in. As it stands, you need to make
> (admittedly tiny) changes to both the C and Lua files to make this
> work. Basic socket support, at least for tcp, is close to a core
> feature of modern scripting...    

AFAICT from the sources socket/ (which can also be named is already a submodule that is require'd from socket.lua. You
can already statically link the so file to your lua interpreter. All you
have to modify is lua.c so that it puts luaopen_socket_core C function
in package.preload Lua table. No change to either LuaSocket C code or
Lua code is necessary. You could even do the same for the Lua files,
embeddeding them in the C code, but that's slightly more work.