lua-users home
lua-l archive

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


On Thu, 6 Oct 2011 11:53:27 -0400
Patrick Donnelly <batrick@batbytes.com> wrote:

> On Thu, Oct 6, 2011 at 4:04 AM, steve donovan
> <steve.j.donovan@gmail.com> wrote:
> > On Wed, Oct 5, 2011 at 7:36 PM, Rob Hoelz <rob@hoelz.ro> wrote:
> >> "How do I tell require to search relative to the current module?"
> >
> > It's a good question, because it illuminates the central role of
> > package.path.
> >
> > The solution I use is to look at _G.arg[0] and work out the base
> > path from that; this seems to work fine and is the basis for
> > app.require_here() in Penlight:  Then we modify package.(c)path
> > accordingly.
> 
> Hmm, I interpreted this question to mean requiring sub-modules. For
> example, instead of socket.lua doing:
> 
> require "socket.http"
> 
> it can instead do
> 
> require "http"
> 
> The solution for this is a new package search loader I would imagine.
> Maybe this isn't what the OP wanted though.
>

That's usually how I interpret the question when someone wants to know
how to implement modules relative to the current module.

Attachment: signature.asc
Description: PGP signature