2011/3/10 Tony Finch
<dot@dotat.at>
The reason for this is that require() can be called any number of times
for the same module and when it is called the second and subsequent times
it just returns the existing instance of the module.
Tony.
The same applies to a
require "lanes".init(n)
idiom.
If I changed Lanes for this to become the 'standard' way of initializing Lanes, then it could be encountered more than once with different parameters. The only difference is that when used, this idiom guarantees that the init function gets called everytime the module is required, and not only the first time, which offers a means of complaining if different parameters are passed. In the case of Lanes, it happens that this parameter only serves to improve performance, but has no effect on available functionality, so it isn't that important. On the other hand, the above idiom has the drawback of the init call being mandatory: I can complete initializations and make the module usable only after the init parameter has been provided. In other words, forgetting to call the init function will leave the module in an unusable state, which would not the case if the parameter were forwarded by the call to require.
Benoit.