lua-users home
lua-l archive

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


> In the main file, I have the following:
>
> local mod=require("xml")
>
> This includes the module from my file "xml.lua" which starts with:
>
> module("MyModules.XML", package.seeall)
>
> After this, MyModules.XML points to the module and the module itself
> works as expected as expected. However, the "require" command returns
> nil and "mod" variable is set to nil! Of course I can manually do
> "local xml=MyModules.XML" afterwards, but is this intended? It seems
> at odds with what is presented in the documentation.

Your problem is, I'm pretty sure, is that require will try to look for the table "xml" in the global table, but not find one. You will see if you leave the string in your require function the same as the string in your module function, you will get the behavior you expect.

If you leave the period in "MyModules.XML" then you may see have future problems in your code. I would see it as generally a very bad idea to use decimals inside your table symbols, as it will confuse those trying to read your code.

HTH,

-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing to do and always a clever thing to say."

-Will Durant