[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: require() relative to calling file
- From: Daurnimator <quae@...>
- Date: Wed, 8 Feb 2017 14:54:50 +1100
On 8 February 2017 at 00:09, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2017-02-07 12:59 GMT+02:00 Javier Guerra Giraldez <javier@guerrag.com>:
>
>> What I would like is that package.searchpath() would replace another
>> character, like '$' with the directory where the function calling
>> 'request' resides. a crude implementation:
> ...
>> function package.searchpath (name, path, sep, rep)
>
> Over to you, supporters of the notion. Javier has reduced the problem
> to a mere monkeypatching of one routine in the package library.
> Try it out. Do you like it?
Note that this solution will break due to the string passed to require
being used in package.loaded.
e.g. if you have the 5 files:
myprogram/main.lua containing: `require "a.foo"; require "b.qux"`
myprogram/a/base.lua
myprogram/a/foo.lua contaning: `require "base"`
myprogram/b/base.lua
myprogram/b/qux.lua containg: `require "base"`
Then b/qux.lua will *not* get what it expects
- References:
- require() relative to calling file, tobias
- Re: require() relative to calling file, Sean Conner
- Re: require() relative to calling file, Russell Haley
- Re: require() relative to calling file, Scott Morgan
- Re: require() relative to calling file, Russell Haley
- Re: require() relative to calling file, Sean Conner
- Re: require() relative to calling file, Russell Haley
- Re: require() relative to calling file, Sean Conner
- Re: require() relative to calling file, Russell Haley
- Re: require() relative to calling file, Stephen Irons
- Re: require() relative to calling file, Javier Guerra Giraldez
- Re: require() relative to calling file, Dirk Laurie