lua-users home
lua-l archive

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


Gé Weijers <ge@weijers.org> wrote:
> On Apr 26, 2007, at 5:03 AM, Thomas Lauer wrote:
> >
> > Yeah, that's one of my pet peeves as well. It would be a really great
> > addition if ll_require() would push further arguments before it calls
> > the loaded module. ll_module() could then simply access these as  
> > further
> > parameters. This should even work with C libraries.
> >
> > Alas, doing this would break most existing module code.
> >
> 
> The arguments passed would come from the 'chunk' that happens to  
> import the module first, and the correct functioning of your code  
> would then depend on the order in which you directly or indirectly  
> import modules. I'm not sure that that's what you'd want from a  
> module system.

Well, it depends. Such a feature would be completely optional to start
with. Someone who doesn't need (or doesn't want) this wouldn't use it in
his or her modules.

Second, any parameter beyond the first (the name) would be optional as
well, much like you can call functions with varying parameter lists and
create some sensible defaults if a parameter is nil. Writers of such
module(s) would structure their code in such a way that they take this
into account.

Third, module parameters might make handling complex systems with many
internal interdependencies and one or two controlling main modules
easier, exactly because it would give module users more control about
how they use a module and modules writers more control about how their
modules are used. I think what you see as a disadvantage can actually be
an advantage. At least in a properly designed system.

Which brings me to point 4: this feature would of course only be used by
people who know what they're doing, like all these dangerous features:-)

-- 
cheers  thomasl

web : http://thomaslauer.com/start