lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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