[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: building a single lua binary with luasocket
- From: <brian@...>
- Date: Fri, 3 Jun 2005 08:55:04 -0000
Diego Nehab <email@example.com> said:
> > I have implimented this now. Can this be documented somewhere ?
> > I will donate the "C" code fragment that does the package.preload
> > initialization.
> I think the best place to document this would be the Wiki. I will write
> about it when I am done with the LuaSocket documentation updates.
> > I still believe it's asking for trouble if two different files import into
> > the same namespace.
> Why is that? I think it is perfectly natural if you want to
> replace or extend the functionality provided by another package.
> The fact that both files are part of the same toolkit makes it even
> safer. :)
Well perhaps I am biased about my experiences with Python where the file
location and it's name determine the namespace. The Python socket module
for instance has a Python part socket.py and a C part _socket. If you
need to access the C routines then you need to use the _socket prefix.
It took some time to understand that the luasocket C and lua modules
imported into the same namespace and that because I initialized the C part
first caused the lua part not to be loaded. That this needs documentation
and explanation I believe is incorrect when it can be made to just work in
both cases. I am certain that others will/have used time finding out this
and then fixing it in various ways.
This is only really a problem when there is a C module and a lua module
which import into the same namespace. Perhaps in this case a seperate
namespace could be used as a general principle?
Anyway I use your method now to avoid patching your code and as a general
method to solve this problem, thanks for your help.