lua-users home
lua-l archive

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



On 10/06/2014 20:41, Coda Highland wrote:
On Tue, Jun 10, 2014 at 3:41 PM, Thiago L. <fakedme@gmail.com> wrote:
My proposal is basically to change require to call the module with args.

Let's say your module looks like this:
print(...)

The current require() does this:

require("mymod","with","args")
mymod

My proposal is to make it do this:

require("mymod","with","args")
mymod    with    args

(PS: Obviously when using require with args it should reload the module
instead of using the loaded one)
This is a very, very common request. Unfortunately, the issue of
caching the module makes it complicated.

Here's one example of a thread:

http://lua-users.org/lists/lua-l/2011-11/msg00178.html

/s/ Adam

Well it could cache the main chunk somewhere...

require("mymod","with","args") => package.mains["mymod"]("mymod","with","args")