lua-users home
lua-l archive

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


Andre Carregal wrote:

Hi,

The Package Compatibility (Compat-5.1) is a set of files which provides an
implementation of the new package model of Lua 5.1 to be used in Lua 5.0.
Compat-5.1 release 3 follows Lua 5.1 work 6 implementation.

The implementation differences could be summarized in:
   * Tables package and package.loaded are linked to functions require()
and module() so that there is no way to change these tables per se, only its
fields.
   * Function require() uses a list of loaders which are functions
responsible for trying to load a module. Table package.loaders store these
functions.

Compat-5.1 is free software and uses the same license as Lua 5.0.

For more information on Compat-5.1 please check
http://www.keplerproject.org/compat/

Any feedback is welcome!

André Carregal
www.keplerproject.org



Compat-5.1 continues to be incompatable with Windows (and Mac?)!

I submitted a patch to someone, but maybe it went to the wrong place....

Here it is.... (perhaps primative - I'm not a Lua expert!):

--
-- Compat-5.1 release 2
-- Copyright Kepler Project 2004-2005 (http://www.keplerproject.org/compat)
--

--
-- avoid overwriting the package table if it's already there
--
package = package or {}

-- Alter as appropriate for your installation
local winpath = ("./?.lua;" ..
                   "e:/lua/lua-5.0.2/?.lua;" ..
                   "e:/lua/lua-5.0.2/?/?.lua;" ..
                   "e:/lua/lua-5.0.2/?/?/?.lua;" ..
                   "e:/lua/lua-5.0.2/bin/init.lua" )

local unixpath = ("./?.lua;" ..
                   "/usr/local/share/lua/5.0/?.lua;" ..
                   "/usr/local/share/lua/5.0/?/init.lua" )

if (os.getenv("WINOS") ~= nil) then
   mypath = winpath
else
   mypath = unixpath
end
package.path = LUA_PATH or os.getenv("LUA_PATH") or mypath

-- Alter as appropriate for your installation
local winCpath = ("./?.dll;" ..
            "e:/lua/lua-5.0.2/?.dll;" ..
            "e:/lua/lua-5.0.2/?/?.dll;" ..
            "e:/lua/lua-5.0.2/?/lib?.dll")

local unixCpath = ("./?.so;" ..
            "/usr/local/lib/lua/5.0/?.so;" ..
            "/usr/local/lib/lua/5.0/lib?.so")

if (os.getenv("WINOS") ~= nil) then
   myCpath = winCpath
else
   myCpath = unixCpath
end

package.cpath = os.getenv("LUA_CPATH") or myCpath

--
-- make sure require works with standard libraries


Dave LeBlanc
Seattle, WA USA