[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Private modules, was Calling module from a C function
- From: Tomas Guisasola Gorham <tomas@...>
- Date: Thu, 26 Apr 2007 09:32:11 -0300 (BRT)
Hi Thomas
> > Have you wrote your own version? I think a copy function
> > is easy to write, but I'm not certain on how to handle function
> > dependencies when importing a function f from module A to module B.
> > What to do if f uses a global g and B already has a member g?
>
> Hm... this should only be of concern if the modules in question use
> 'seeall'. Don't use it and this sort of problem can't happen: all
> accesses to functions are then "hard-wired" in their respective modules
> and as such won't go through an __index metacall. (Of course, it is
> still perfectly possible to willy-nilly change any and all addresses in
> the module tables, but this has to be done explicitly.)
I mean:
== A.lua ==
module"A"
g = 10
function f (x) return x+g end
== B.lua ==
local A = require"A"
module"B"
g = 20
import_f_from_A
What will be the result of B.f(2) ?
> > But `require' only passes its first argument to the script :-(
>
> 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.
Why?
Regards,
Tomás
- References:
- Re: Private modules, was Calling module from a C function, Jim Whitehead II
- Re: Private modules, was Calling module from a C function, Roberto Ierusalimschy
- Re: Private modules, was Calling module from a C function, Thomas Lauer
- Re: Private modules, was Calling module from a C function, Tomas Guisasola Gorham
- Re: Private modules, was Calling module from a C function, Thomas Lauer