lua-users home
lua-l archive

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


  Okay, some more playing around, I think I got this working.
So I have mod-v1.2.3 and mod-2.0.1.  To start with, they can't have those
names, they need to be mod-v1.so and mod-2.so.  Then, to include these:

	mod123_1 = require "mod-v1"
	mod123_2 = require "mod-v1.2"
	mod123_3 = require "mod-v1.2.3"

	mod201_1 = require "mod-2"
	mod201_2 = require "mod-2.0"
	mod201_3 = require "mod-2.0.1"

Furthermore, from some investigation, the module is only found by the last
searcher, the *all-in-one* loader.  So mod123_1, mod123_2 and mod123_3 are
all the same module; same with mod201_1, mod201_2 and mod201_3.

  This is ... less than useful.

  This can work if I name the modules mod-1-2-3.so, mod-1-2-4.so (which I
added, testing this out) and mod-2-0-1.so.  So now I can do:

	local a = require "a" -- calls require "mod-1-2-3"
	local b = require "b" -- calls require "mod-1-2-4"
	local c = require "c" -- calls require "mod-2-0-1"
	
	a.foo()
	b.foo()
	c.foo()

	This is module a
	This is module mod-1.2.3 -- print statement out of date
	This is module b
	This is module mod-1.2.4 -- I didn't bother changing these
	This is module c
	This is module mod-2.0.1

  Man, is that unintuitive.  But it does work with Lua modules as well.  I
can rename a.lua, b.lua and c.lua to a-1-0-0.lua, a-1-1-0.lua and
a-2-0-0.lua, change the above to:

	local a = require "a-1-0-0"
	local b = require "a-1-1-0"
	local c = require "a-2-0-0"

and it still works.  Ugly though.

  -spc