Parameters to require

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Parameters to require

Francisco Santanna
Hi,

Can I send others parameters to require() besides the module name?
Something like:

test.lua:
require('module', param1, param2)

module.lua:
local params = {...}
module 'module'
...

Thanks,
Francisco

Reply | Threaded
Open this post in threaded view
|

Re: Parameters to require

Roberto Ierusalimschy
> Can I send others parameters to require() besides the module name?

No. This could be missleading, because when you call require it may
do nothing (if the module is already loaded); in that case would it
through away the extra parameters?

If you need to initialize your module in a non-fixed way, it is cleaner
to have an explicit function for the task.

-- Roberto