protocols, inheritance and polymorphism
Jacek Generowicz
jacek.generowicz at cern.ch
Thu Nov 25 03:44:32 EST 2004
More information about the Python-list mailing list
Thu Nov 25 03:44:32 EST 2004
- Previous message (by thread): protocols, inheritance and polymorphism
- Next message (by thread): protocols, inheritance and polymorphism
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Dan Perl" <danperl at rogers.com> writes: > Can you elaborate on problems that static languages have with OOP? They make dynamic polymorphism impossible. Which is why most object-oriented C++ programs are dynamically typed; only the programmer is burdened with the work that the mostly-absent dynamic type system should be doing. Dynamic polymorphism crucially requires knowledge of the *run-time* (dynamic) type of objects, in order to be able to dispatch to the correct method. In C++ you turn your classes into dynamically typed ones with the "virtual" keyword, which introduces a vtable and run-time type identification (RTTI). As long as you are only interested in calling methods which are declared in some base class, this dynamic type systems looks almost satisfactory. As soon as you want to use a method present in the subclass but not in the superclass, it is up to you to faff around with dynamic_cast and checking of the resulting pointer; all stuff which a dynamic type system should be doing for you, but C++ makes you do yourself because it pretends that your programs are statically typed when, in fact, they are dynamically typed.
- Previous message (by thread): protocols, inheritance and polymorphism
- Next message (by thread): protocols, inheritance and polymorphism
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list