[C++-sig] Re: sub module support in V2

David Abrahams david.abrahams at rcn.com
Wed Jun 5 20:09:23 CEST 2002


From: "Dave Hawkes" <daveh at cadlink.com>

> "Dave Hawkes" <daveh at cadlink.com> wrote in message
> news:adlgit$hmf$1 at main.gmane.org...
> >
> >
> > Unfortuantely, yes, something will have to be done about Py_InitModule,
> > which call PyImport_AddModule. Maybe we should just delete the
sys.modules
> > entry that is produced as a result? Unless there is a more elegant
> solution.
> >
> > I'd also like to add some code that checks if a sub-module of the same
> name
> > already exists and return a reference to that rather than a new
sub-module
> > so we don't lose previous definitions.
> >
>
> No, this is not correct! I think we need to do something along these
lines:

Just who are you arguing with here?

When the two of you work things out, please submit a patch ;-)

BTW, I am not happy about the interface in which sub() chaining introduces
another level of nesting. I would prefer it if you could find a way to get
something like this to work:

module("outer")
    .add(
        module("inner1")
            .def(...)
            ...
        )
    .add(
        module("inner2")
            .def(...)
            ...
    )

I realize this is a bit problematic, especially since class_<> instances
now get their __module__ attribute from the module they are added to. I'm
just asking you to think about it.

Perhaps Joel de Guzman has some creative phoenix-like ideas about this...
Joel?

-Dave








More information about the Cplusplus-sig mailing list