[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to query current path from a library?
- From: Jonathan Castello <twisolar@...>
- Date: Mon, 22 Feb 2010 17:20:20 -0800
That's... interesting, and it would certainly, work, but aren't files
basically functions once loaded up anyways? It seems a little
redundant to be wrapping the whole file in yet another function. Is
there a technical reason why require() can't be modified to pass
through extra arguments?
~Jonathan
On Mon, Feb 22, 2010 at 5:13 PM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> On a related note, is there any chance that Lua 5.2 will allow
>> require() to take additional parameters that will be passed to the
>> loaded chunk? That's the only reason I really need to use loadfile(),
>> to pass my own parameters. require() already passes the module name
>
> If write your Lua module like this:
>
> return function (...)
> ...
> end
>
> Then you can require this module as
> require("mymodule")(100,200,300)
>
> If all your modules are like that, then you can redefine require as:
> do
> local old_require=require
> function require(name,...) return old_require(name)(...) end
> end
>