lua-users home
lua-l archive

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


Hi Diego,

> > For example, one cannot create the module 'mymodule.assert' or
> > 'mymodule.error' if the basic library is loaded in the Lua state.
> 
> It seems to be working fine here. Can you send a small set of scripts
> that fails? I wrote a file called error.lua, and placed in a directory
> test.

OK, most probably I didn't make myself clear enough. Maybe I should better 
have said that one cannot create the module 'mymodule.assert' or 
'mymodule.error' once the module 'mymodule' were previously created using 
the module function. This happens because all global variables are 
accessible through the table of a module (in this case, the table 
'mymodule'). This way 'compat-5.1.lua' thinks there is some conflict at 
'mymodule.error'. A small script that shows the problem is:

Lua 5.0.2  Copyright (C) 1994-2004 Tecgraf, PUC-Rio
> module "mymodule"
> module "mymodule.error"
compat-5.1.lua:200: name conflict for module `mymodule.error'
stack traceback:
        [C]: in function `error'
        compat-5.1.lua:200: in function `module'
        stdin:1: in main chunk
        [C]: ?


> In Lua 5.1, we have the _M field in the namespace, pointing to itself.
> It works like the _G field, but only for modules. The new version of
> compat will do the same.

Thanks! That will do the trick ;-)

--
Renato Maia.