Re: Registries [2]
David Abrahams <[email protected]>
| Newsgroups | gmane.comp.lib.boost.langbinding |
|---|---|
| Message-ID | <[email protected]> |
Daniel Wallin <[email protected]> writes: >> > If that is the case, converters need to be added to the local >> > registry from the outside. So when saying "import converters from >> > module X" we are really saying "when module X adds a converter to >> > it's local registry, add it to mine as well". >> >>I don't think we have to get that fancy. We can just >>initialize module X if it isn't already, and then import all the >>converters that it has registered. I'm not too worried about >>supporting dynamic registration of converters after module >>initialization time. > > Right, or rather; demand that the user initializes module X before. > This doesn't play well with automatic importing though. > >>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. >> > 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. > 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? -- Dave Abrahams Boost Consulting www.boost-consulting.com ------------------------------------------------------- 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