in 5.1, find pathname for required module?

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

in 5.1, find pathname for required module?

Norman Ramsey
I have a large installed based of Lua 5.1 code (about 75,000 lines),
and I've recently found it useful to write Lua code that is a lot
like Make rules.  This code needs to rebuild files when the code
itself has changed, so I need to get a timestamp on the file in
which the code lives.  I see that in Lua 5.3, there are facilities
like `package.searchpath` and an extension to `require` (relative to 5.1)
that can pass an extra parameter.  Can anyone suggest a way to
replicate this functionality in 5.1?


Norman




Reply | Threaded
Open this post in threaded view
|

Re: in 5.1, find pathname for required module?

Luiz Henrique de Figueiredo
> I see that in Lua 5.3, there are facilities
> like `package.searchpath` and an extension to `require` (relative to 5.1)
> that can pass an extra parameter.  Can anyone suggest a way to
> replicate this functionality in 5.1?

I haven't tried it, but from a quick look at the 5.1 loadlib.c, it
seems that it's just a matter of backporting the 5.3 functionality to
5.1.

Reply | Threaded
Open this post in threaded view
|

Re: in 5.1, find pathname for required module?

Thijs Schreijer
In reply to this post by Norman Ramsey


On 10 Nov 2018, at 13:51, Norman Ramsey <[hidden email]> wrote:

I have a large installed based of Lua 5.1 code (about 75,000 lines),
and I've recently found it useful to write Lua code that is a lot
like Make rules.  This code needs to rebuild files when the code
itself has changed, so I need to get a timestamp on the file in
which the code lives.  I see that in Lua 5.3, there are facilities
like `package.searchpath` and an extension to `require` (relative to 5.1)
that can pass an extra parameter.  Can anyone suggest a way to
replicate this functionality in 5.1?


Norman


I don’t know if it's of any help, but there is a pure-lua implementation of ‘require’ available. I think by Rob Hoelz. You might be able to adapt those?


But this is the one I was looking for: https://github.com/hoelzro/lua-procure 

Thijs