Re: Could require take multiple arguments?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Could require take multiple arguments?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: 2016年1月28日 22:39:48 -0200
> when i think of a multi-parameter `require`, i imagine it as a way to
> pass extra arguments to the required chunk
That would complicate the semantics of `require`, which loads modules
just once per session. Would a different set of extra arguments force
the module to be reloaded?
If you want to pass extra arguments to a module, just write your module as:
private code
return function (...)
code to be run when required
end
and use
function xrequire(m,...)
return require(m)(...)
end