lua-users home
lua-l archive

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



I know...   In this case, the module is about interconnection between the states, so it naturally needs to have some "universal" access.   I will work on it.


Gé Weijers kirjoitti 2.4.2007 kello 23:31:

If you depend on the 'feature' of being able to load a module twice with non-shared local variables your code is going to be severely non-portable.  That may not be a problem for an OS X-only application, but I prefer to keep OS dependencies to a minimum. 


On Apr 2, 2007, at 4:10 PM, Jerome Vuarand wrote:


The problem comes from the fact that Asko use separate Lua states. If a
binary module is required in two independents Lua states, it's
initialization function must be called twice. Since binary modules may
not be reentrant and use globals to store "Lua-state"-specific
information, having it loaded twice with private static data allows to
avoid collisions in memory between the two instances of the module,
while the package system still ensure that all require in the same Lua
state will always return the same module table.

If you make the static data shared (by removing the aforementioned
flag), to allow communication between the two instances of the module,
you have to make sure all binary modules you load don't store
"Lua-state"-specific information in static variables. For example you
can't store registry indices in globals and share them between Lua
states, since each has its own registry.



--
Gé Weijers