Could Python supplant Java?

Bernhard Herzog bh at
Fri Aug 23 14:42:35 EDT 2002

"James J. Besemer" <jb at> writes:

> Casts are NOT automatically generated for pointers, so the following
> code WILL exhibit the expected Polymorphism without virtual functions
> (classes A and B as above):
>     void foo( A* arg ){
>         arg.x;
>;        // calls A or B depending on type of arg
>     }
>     A a; B b;
>     foo( &a );    // foo will call
>     foo( &b );    // foo will call

No, foo(&b) will call A::bar unless bar is virtual.

> Paul Foley wrote:
> > And just what do you think your C++ vtable lookup is?
> > You've failed to demonstrate that.  You had to resort to late binding,
> > via `virtual', to get polymorphism in C++
> "Early binding" generally means resolved at or before link time. 

However, which virtual method bar is called in a function like this

void foo(A * a)

Is *not* determined at link time.


Intevation GmbH                       

More information about the Python-list mailing list