package.searchers

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

package.searchers

aryajur
Hi,
         I added a simple package.searcher function in Lua 5.3 as follows:

package.searchers[5] = function(...)

local t = {...}
print(#t,t[1])

end

but now when I do require("nonexistentmodule") then I don't see this function being called. How are the searchers supposed to work with require? 

Thanks,
Milind

Reply | Threaded
Open this post in threaded view
|

Re: package.searchers

Philipp Janda
Am 10.08.2015 um 20:53 schröbte Milind Gupta:
> Hi,

Hi!

>           I added a simple package.searcher function in Lua 5.3 as follows:
>
> package.searchers[5] = function(...)
>
> local t = {...}
> print(#t,t[1])
>
> end
>
> but now when I do require("nonexistentmodule") then I don't see this
> function being called. How are the searchers supposed to work with require?

Your code works fine here (meaning it prints `1    nonexistentmodule`
before `require` errors out). Same with Lua 5.2.

>
> Thanks,
> Milind
>

Philipp



Reply | Threaded
Open this post in threaded view
|

Re: package.searchers

Roberto Ierusalimschy
In reply to this post by aryajur
>          I added a simple package.searcher function in Lua 5.3 as follows:
>
> package.searchers[5] = function(...)
>
> local t = {...}
> print(#t,t[1])
>
> end
>
> but now when I do require("nonexistentmodule") then I don't see this
> function being called. [...]

I do. What do you see?

-- Roberto

Reply | Threaded
Open this post in threaded view
|

Re: package.searchers

aryajur
In reply to this post by Philipp Janda
Thanks I see it. I was checking the bottom of the error message. I understand the operation also a little better now.

Thanks,
Milind


On Mon, Aug 10, 2015 at 12:26 PM, Philipp Janda <[hidden email]> wrote:
Am 10.08.2015 um 20:53 schröbte Milind Gupta:
Hi,

Hi!

          I added a simple package.searcher function in Lua 5.3 as follows:

package.searchers[5] = function(...)

local t = {...}
print(#t,t[1])

end

but now when I do require("nonexistentmodule") then I don't see this
function being called. How are the searchers supposed to work with require?

Your code works fine here (meaning it prints `1    nonexistentmodule` before `require` errors out). Same with Lua 5.2.


Thanks,
Milind


Philipp