[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Best way to pass options to a module at require time?
- From: Benoit Germain <bnt.germain@...>
- Date: Thu, 10 Mar 2011 15:37:13 +0100
The Lanes module, when required, creates a certain number of hidden Lua states to store data in transit in linda objects between lanes. It might be desirable, depending on the usage scenario, to initialize a variable number of those so-called keeper states (currently I create only one). I have tried to modify the Lanes code do support this like such:
require( "lanes", n)
Unfortunately, additional parameters passed to require() are lost and the module initialisation function doesn't get them. I also can't set this option after the module has been required, because initialisation creates a linda object, and all the necessary keeper states must exist at that point. Note that if this was supported, multiple requires of Lanes with different values of n wouldn't be important, because the creation of these keeper states is done only once, even when the module is required from several different Lua states.
Am I definitively stuck to a compile-time defined fixed number of keeper states, or is there some way I haven't seen to do what I want? An option would be for Lua 5.2 to support the propagation such additional parameters :-).