lua-users home
lua-l archive

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


In Lua 5.3 I see the following

--- Module file begin
xml = require("LuaXml")
local xml = xml

local M = {}
package.loaded[...] = M
_ENV = M

-- Module code here
xml.load("File.xml") 

--- Module file end

Here LuaXml.lua is something like
local xml = require("LuaXml_lib")     --- dll file
--- Module code
return xml


The following does not work and gives error that trying to index a nil value on the load statement pointing to the C module

--- Module file begin
local M = {}
package.loaded[...] = M
_ENV = M

xml = require("LuaXml")

-- Module code here
xml.load("File.xml")    -- ERROR attempt to index nil value in LuaXml_lib.load

--- Module file end


The following gives the error that specified procedure not found

--- Module file begin
local M = {}
package.loaded[...] = M
_ENV = M

xml = require("LuaXml_lib")

-- Module code here
xml.load("File.xml")    -- ERROR attempt to index nil value in LuaXml_lib.load

--- Module file end



Please can anyone help me understand why the errors are happening and what would be the right way to load another module inside a module successfully.

Thanks,
Milind