Re: Re: Registries [2]
Daniel Wallin <[email protected]>
| Newsgroups | gmane.comp.lib.boost.langbinding |
|---|---|
| Message-ID | <[email protected]> |
At 13:40 2003-07-27, David Abrahams wrote: >Daniel Wallin <[email protected]> writes: > > > At 01:26 2003-07-27, David Abrahams wrote: > >>Daniel Wallin <[email protected]> writes: > >> >>Hmm, if there was really a mutual dependency we might have an issue, > >> >>but we could still handle it with a simpler mechanism that simply > >> >>deferred imports until initialization was completed. > >> > > >> > I guess, but it would be nice to handle it without introducing code in > >> > the dispatch functions. Which is the only place I can think of where > >> > we could defer importing to. > >> > >>In Boost.Python, the module initialization function is special; we > >>actually generate it with a macro and it calls what the user wrote > >>(for exception-handling purposes), so we can easily generate code > >>there to handle any deferred imports. > > > > Right, but how do you call this code after all other modules has been > > initialized? > >You keep a count of modules being initialized in each thread and when >it falls back to zero you do the imports. > > > Also, at least in lua. Modules could be loaded at any time, so there isn't > > really a point where we can assume everything is loaded and import > > converters. > >Can't you do something similar to the above? I don't think so. When I said "at any time" I didn't mean concurrently. Consider (lua code): loadmodule "X" -- exposes f(std::vector<double>) loadmodule "Y" -- exposes some convenience converters -- lua -> C++ std::vector<double> We would really like for module X to be able to use the converters introduced by module Y here, but module X is already initialized when module Y's converters are created. > >> >> > How are extensions to be registered in this central registry? In my > >> >> > previous post I proposed that they should be registered with a > >> >> > string literal identifier. > >> >> > > >> >> > register_extension("my_extension"); > >> >> > > >> >> > How does this fit in with pythons module system? (Note that we are > >> >> > really registering the extension, and not modules). > >> >> > >> >>Every extension is a module (not nececssarily the other way around), > >> >>so I see no reason not to register the extension by its module name > >> > > >> > I guess in python you can ask the interpreter state for the current > >> > module name? > >> > >>Erm, I'm not sure you can. It is supplied as part of the module > >>initialization function; in fact, it is stored in the module object as > >>its __name__ attribute, so we can get it thence, assuming we can get > >>to the module. > > > > Ok. > > > >> > In lua this isn't possible though, so we would need some user defined > >> > identifier instead. > >> > >>You've gotta have the module or its name stored somewhere, dontcha? > > > > Other than in the .so filename? No. > >Why not just store it then? When you create it, stick a string in its >__name__ attribute. I don't know what this means, create what? And what string? And how? :) --- Daniel Wallin ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01