[Python-Dev] type categories (original) (raw)
Guido van Rossum guido@python.org
Fri, 13 Sep 2002 00:37:57 -0400
- Previous message: [Python-Dev] type categories
- Next message: [Python-Dev] type categories
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> Why do keep arguing for inheritance? (a) the need to deny inheritance > from an interface, while essential, is relatively rare IMO, and in > most cases the inheritance rules work just fine; (b) having two > separate but similar mechanisms makes the language larger. > > For example, if we ever are going to add argument type declarations to > Python, it will probably look like this: > > def foo(a: classA, b: classB): > ...body...
I'm curious, and I don't recall having seen anything about this: why wouldn't we simply use attributes to hold this information, like slots? After all, attributes get inherited, too, and there's no need to pretzel the syntax. Using attributes IMO would make it easier to handle the case where derived classes need to mangle type and interface declarations.
That's exactly what Zope does with the inherits attribute.
But it's got limitations: there's only one inherits attribute, so it isn't automatically merged properly on multiple inheritance, and adding one new interface to it means you have to copy or reference the base class inherits attribute.
Also, slots is provisional. The plan is for this to eventually get nicer syntax (when I get over my fear of adding new keywords :-).
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] type categories
- Next message: [Python-Dev] type categories
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]