Re: syntax suggestion
David Abrahams <[email protected]>
| Newsgroups | gmane.comp.lib.boost.langbinding |
|---|---|
| Message-ID | <[email protected]> |
Alexander Nasonov <[email protected]> writes: > Daniel Wallin wrote: > >> Alexander Nasonov wrote: >>> I'd like to see inheritance more natural in langbinding. What do you >>> think if inheritance relationships could be exposed like this: >>> >>> class_<C>("C") >>> , public_<A> >>> , public_<B> >>> [ >>> // ... >>> ]; >> >> The [] syntax still won't work (IMO) for declaring classes. So you'd end >> up with something like: Not to mention that the []s will bind more closely to public_<B> than to the class_ object. If we end up building an AST for the class declaration and then walking over it to evaluate it, I fear we're going to end up overstressing many compilers. >> class_<C>("C") >> .public_<A>() >> .public_<B>() >> .def(..) >> .def(..) >> ; > > I think it's possible to implement []-style but I'm not sure how much time > it would take to compile. Agreed, it's possible. The compilation time is IMO a serious concern. >> Although it looks kind of cool, 'public_' is completely redundant since >> we are only interested in accessible bases anyway. > > Not sure about this. We may need access to protected C++ bases from non-C++ > class (I don't know how to implement it elegantly, though). Actually I think the issue here is that we don't need to represent access. Why would the system care whether a base was private or protected or public? >> When in doubt I tend to go for the less verbose and less complicated >> alternative, so I guess I like the original version is better: >> >> class_<C, bases<A, B> >("C") >> .def(..) >> .def(..) >> ; >> >> Here are some other possibilities: >> >> // Cool, but not very portable >> class_<C(A, B)>("C") I like the syntax; I guess we need to decide whether we care about older compilers or not. >> .def(..) >> .def(..) >> ; >> >> // Just add more parameters to class_<>, complicates >> // the metaprogramming Definitely problematic, especially if you want to be able to pass other parameters. >> class_<C, A, B)>("C") >> .def(..) >> .def(..) >> ; >> >> I'm not sure if either one has any significant benefits from the >> original though. >> >> I think we need more opinions, anyone? The only advantage I can see to using the []s is that it becomes a bit cleaner to define nested classes. -- Dave Abrahams Boost Consulting www.boost-consulting.com ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click