lua-users home
lua-l archive

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



On Jul 22, 2009, at 2:03 PM, Jerome Vuarand wrote:

With these constructs you can have your Lua modules really independent
from their path and name, which let you move them between namespaces.

Hmmm... right... you are trading one set of problems for another, e.g.:

% cat TestFoo.lua
module( ..., package.seeall )

print( _NAME )

% cat TestBar.lua
module( ..., package.seeall )

print( _NAME )

% cat TestBaz.lua
print( require( 'TestBar' )._NAME )
print( require( 'TestFoo' )._NAME )

% lua TestBaz.lua
TestBar
TestBar
TestFoo
TestFoo

% luac -o TestBaz.luac TestFoo.lua TestBar.lua

% lua TestBaz.luac
lua: TestFoo.lua:1: bad argument #1 to 'module' (string expected, got nil)
stack traceback:
	[C]: in function 'module'
	TestFoo.lua:1: in main chunk
	(luac): in main chunk
	[C]: ?

Ooooops... your code now depends on its physical representation... oh, well...

Cheers,

--
PA.
http://alt.textdrive.com/nanoki/