[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Re[2]: import and LuaBinaryModules
- From: "Peter Hill" <corwin@...>
- Date: Fri, 7 Mar 2003 10:34:37 +0800
Peter Hill:
> Ah, but as far as:
> import "a.b.c"
> goes the name clashs problem only occurs with *other modules*, which
> can be handled by whatever module naming and/or versioning
> convention may be decided upon.
Thatcher Ulrich:
> Yes -- exactly! The problem must be solved by packagers and module
> maintainers.
I agree. Module identification (including version numbering) is a key issue
to be resolved.
> Once the problem is solved there, it is solved for everybody; there is no
> problem in Lua's global table, if the module names are unambiguous.
Not at all!
Just because the module names are unambiguous with each other does not mean
they won't conflict with a user's global. Mixing the module naming
convention in with general globals is just an (unnecessary) mess. Variable
names (including globals) are by definition a programmer's choice, whereas
module names must match a (yet to be specified) convention.
And requiring that the module be assigned to a fixed global is just
pointless! Any chunk of code that wishes to make use of a module should
import it itself anyway (and there is no harm in doing so since once a
module is loaded once that reference is reused) at which time it is free to
choose how to name it for personal use. Each program unit makes its own
choice. Eg:
main.lua:
complex = import "Complex"
a = complex.new(11,22)
dofile "foo.lua"
b = crand()
foo.lua:
local c = import "Complex"
function crand()
return c.new(random(),random())
end
*cheers*
Peter Hill.