lua-users home
lua-l archive

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


* Mark Hamburg:

> I'll admit I've never been a fan of nested modules, but that may
> just be the Oberon bias showing through. But if one must have
> hierarchical modules, then from a registry standpoint 'require
> "foo.bar"' is really just the same as a non-hierarchical module
> named "foo.bar". If you want this accessible via the module foo,
> then you simply re-export "foo.bar" under the name "bar" when you
> build foo.
>
> 	-- foo.lua
>
> 	module( ... )
>
> 	bar = require "foo.bar"

The holy grail in this area is open, nested submodules, that is, you
can inject a module into the hierarchy without editing other source
files.  It seems secondary if this injection has got a semantic effect
(it has in Ada, but not in Java or Perl), it's mostly a syntactical
thing.

> I would like a system that allowed for a top-level public module and
> private sub-modules that could only be imported by the top-level
> module -- i.e., I could do

> 	-- foo.lua
>
> 	module( ... )
>
> 	local imp = require "imp"

Python has got something which is called relative imports.  This
functionality appears to be rare, it's often the other way round, that
submodules receive access to internals of the parent module.
Importing submodules then tends to cause dependency loops.