lua-users home
lua-l archive

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

Rici Lake wrote:

On 17-Jan-06, at 12:10 PM, D Burgess wrote:

Methinks Edgar had in mind that you would use

require"osex"   or require"os.ex"

given that you writing a C module , you can populate whicever table you
like, in this case os.

That was my thought. In fact, you can even return the os table. In fact, you can even return the os table *unmodified*. So an unextended osex package is possible :)

In other words:

local os = require "osex"

throws an error if you have an implementation which is not aware of osex.

If it doesn't, you can check for the existence of an API:

local sleep = assert(os.sleep, "This package needs sleep")

I sure don't like the idea of a successful load of "osex" NOT populating some table with a well known set of functions. If sleep() is part of osex, then it should be there if the load is successful.

I am liking the idea of 'require "osex"' populating the real 'os' table, if it exists. If not, osex should load the equivalant of the functions from 'os' and then add its own and return that table. That way 'osex' is always a superset of 'os' and all the functions are in one place. In fact, I have never seen any implementations where 'os' is supplied as a loadable module, so why not just name this extension 'os' and always have it include the proposed functions as well as those in the existing 'os' package?

chris marrin                ,""$,          b`    $                             ,,.
                        mP     b'                            , 1$'
        ,.`           ,b`    ,`                              :$$'
     ,|`             mP    ,`                                       ,mm
   ,b"              b"   ,`            ,mm      m$$    ,m         ,`P$$
  m$`             ,b`  .` ,mm        ,'|$P   ,|"1$`  ,b$P       ,`  :$1
 b$`             ,$: :,`` |$$      ,`   $$` ,|` ,$$,,`"$$     .`    :$|
b$|            _m$`,:`    :$1   ,`     ,$Pm|`    `    :$$,..;"'     |$:
P$b,      _;b$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'