2 ms·
"If you want to inherit from an object, just create a class based on that object" is a description of how you'd imitate prototype inheritance in a language that
by chc 5y ago
"If you want to inherit from an object, just create a class based on that object" is a description of how you'd imitate prototype inheritance in a language that only has class-based inheritance. It does not mean you're actually looking at a prototype-based language, and in fact strongly suggests the opposite. You can't get inheritance in Python without engaging with the class system.
I suppose you could just say that classes are a particularly restricted sort of prototypes, and thus any class-based language is effectively prototype-based. But at that point "<OOP language> has prototype inheritance" is just tautological based on the set of definitions you've chosen.
- mjburgess 5y agoIt's not tautological. I don't think C#, C++, Java, etc. can have classes proxy for objects. Classes there aren't objects. You cannot write "return NewClass". Python is prototypal in just the same way js is: inheritance is a daisy-chain of references between objects. JS is "maximally prototypal" if you like, where any object may be refernced. In python, only objects of type "type": but that isn't a big restriction, as shown.