[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion for Lua 5.3.0 -- require search paths
- From: Chris Emerson <chris-lua@...>
- Date: Mon, 7 Apr 2014 10:46:50 +0100
On Sat, Apr 05, 2014 at 10:41:31PM +0200, Petite Abeille wrote:
> On Apr 5, 2014, at 10:09 PM, tonyp@acm.org wrote:
>
> > I think the first place to look for required modules would be the (main)
> > script?s directory. That also allows to override general libraries with
> > customized versions using the same name but placing them in the app?s
> > folder.
>
> One relatively painless way to achieve this is to (1) look at where the main
> script was loaded from (e.g. debug.getinfo( 1, 'S' ).source) (2) Add that
> path to package.path (3) There is no step (3).
I guess that works (if you're willing to make use of the debug library), but
the main problem for me is that you've got to include the code to find the
source, parse it/alter to get the path (possibly handling different filesystem
types - Unix, case-insensitive Windows, etc.), in every Lua script. By its
nature, you can't just pop it into a module you require().
Chris
- References:
- Re: Running multiple threads in a lua state, Coroutines
- Re: Running multiple threads in a lua state, Luiz Henrique de Figueiredo
- Re: Running multiple threads in a lua state, Coroutines
- Re: Running multiple threads in a lua state, Sean Conner
- Re: Running multiple threads in a lua state, Coroutines
- Re: Running multiple threads in a lua state, Sean Conner
- Re: Running multiple threads in a lua state, Rena
- Re: Running multiple threads in a lua state, Coroutines
- Suggestion for Lua 5.3.0 -- require search paths, tonyp
- Re: Suggestion for Lua 5.3.0 -- require search paths, Petite Abeille