lua-users home
lua-l archive

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


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.