lua-users home
lua-l archive

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


>> PS: I don't like the name osex.  I'd simply put them into os.

> I don't think that's possible using the 5.1 package model. I suppose it
> is possible to make:

>      require "osex"

> add things to the 'os' table, assuming it exists. But that seems, at
> least, poor practice.

It is possible in the 5.1 package model, but you still
have to know what you're doing:

in file os/ex.lua (or where-ever):

    -- make sure that "os" is loaded first, otherwise
    -- subsequent require("os") calls would only return our
    -- extension set...
    require "os"

    -- now use the same table as package "os"
    module "os"

    -- all your os.ex stuff goes here...

    -- don't forget to return our own module table or subsequent
    -- require("os.ex") calls will simply return true...
    return _M

Both Diego Nehab and myself have proposed alternatives for this (no
need to actually require "os" first nor to return the module table.)
Maybe this sort of thing is just not common enough (or poor practice,
like you said?)

--
Wim