lua-users home
lua-l archive

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


> Luiz, it would be nice if the loadlib code were platform independant
> from the lua side, that is, in unix it would look like:

Currently, our idea is to put the minimum in C, and everything else in
Lua. Typically, each module in C would have a companion file in Lua:
this Lua file could be very small, more or less like this:

    -- Lua file for module Xuxu: xuxu.lua
    -- Config part; set to your system
    local libdir = "/usr/local/lua/"
    local modname = "xuxu.so"
  
    local f = loadlib(libdir..modname, "xuxuopen")
    if not f then error (...) end
    f()   -- open module

You put xuxu.so anywhere, adjust xuxu.lua, and put xuxu.lua in a
directory on your LUA_PATH; than you use it as

    require "xuxu"

For the user, it doesn't matter whether this is a C module or a Lua
module (or a mixed one).

-- Roberto