lua-users home
lua-l archive

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


On Mon, Jul 11, 2005 at 11:33:50AM -0300, Renato Figueiro Maia wrote:

> > I don't see a problem in always trying to load "a.meta" on require"a.b"
> > (don't really like the name "core" for this).
> 
> But if you really want to stick to this solution, if possible, I'd like to 
> ask you to pick up some uncommon file name pattern. Instead of '?/meta' 
> something like '?/?' or '?/YouWontWantToNameAModuleLikeThis'. ;-)

I think the (quite reasonable) Python solution to this problem is to
name the file __init__.py

Would the problem be helped if C-modules were allowed more intelligence
in the loading process?  

That is, the problem seems to be two-fold:

1. People want to distribute a small set of files for "production"
   use.  
   
For all-Lua code, a simple solution to this is to write a zip-file
loader.  

2. People want to distribute hierchical C-modules and mixed C/Lua
   modules.

The zip-file solution isn't really feasible for those using the dlfcn
loaders (dlopen and friends) under Unix, as they want specific
filenames, which we can't fake as well.  I don't know much about the
Windows equivalent, but I can guess it has issues, too.

For hierchical C modules, code could be rolled into one so/dll, and any
Lua code could be compiled into the DLL for production use, or attached
to the end of the so/dll, etc.  I've written at least one way to compile
Lua bytecode into a C file, which I'll publish if there's interest, and
I'm sure there are 100 more like it.

The module system functionality is then a problem.  To the best of my
knowledge (from the compat-5.1 code), the default loader predicates on a
1-to-1 file/module correspondence.  We could allow so/dll modules to
break this assumption by exporting a sub-loader function (lualoader_XXX,
for instance) that would be responsible for handling all loading tasks
for the module's submodule.

Cheers!

-- 
Shannon Stewman         | Let us walk through the waning night,
Caught in a whirlpool,  | As dawn-rays tickle our toes, the dew soothes
A quartering act:       | Our blistered soles, and damp bones stir
Solitude or society?    | As crimson cracks under the blue-grey sky.