
"JH" == Jeremy Hylton <jeremy@alum.mit.edu> writes:
"DA" == David Abrahams <dave@boost-consulting.com> writes:
DA> I was going to say that is seems to me if you can dynamically DA> inject base classes in Python there's no problem using DA> inheritance to do this sort of labelling. However, on third DA> though, maybe there is a problem. Suppose you have an DA> inheritance chain A->B->C...->Z and I come a long later to say DA> that A fulfills interface II and add II to A's bases. Which of DA> A's subclasses also fulfill II. I might not know. I might not DA> even know about them. For this, maybe you'd need a way to DA> express inheritance that goes just "one level deep" (i.e. A DA> inherits II publicly, but nothing else does). And that might DA> just screw with the notion of inheritance enough that you want DA> a separate parallel mechanism. DA> So I guess I'm back to where I was before. Inheritance DA> probably doesn't work out too well for expressing "satisfies DA> interface". JH> I had similar third thoughts a couple of weeks ago :-). So I JH> guess I agree with you. I tend to agree as well. But to play devil's advocate for a moment: I think Guido said that inheritance won't be the only way to spell conforms-to, but it'll be the predominately common way. So you'd definitely need a way to spell that outside of inheritance as your example clearly shows. Which means that any conformsto() function will have to be more complicated because it'll need to check both mechanisms. Is that a worthwhile price to pay to allow conforms-to-by-inheritance? What I don't like about the inheritance mechanism is that the syntax isn't explicit. I look at a class definition and I don't really know what's a base class for implementation purposes and what's an interface assertion. It might even be difficult if I had the source code for all the classes in the base class list if there's little except convention to syntactically distinguish between a class definition and an interface definition (no keyword, but just a stylized bunch of defs). I think it's going to be important to know what's an interface and what's a base class. Naming conventions (IThingie) can help but aren't enforced. -Barry