Could Python supplant Java?
Roy Smith
roy at panix.com
Thu Aug 22 08:21:47 EDT 2002
Paul Foley <see at below.invalid> wrote:
> SomeType foo(A x)
> {
> ...
> x.bar(...);
> ...
> }
>
> there is no way the compiler can tell at compile time whether x.bar is
> going to be A.bar or B.bar at run-time -- it depends on the caller!
To make Paul's point even stronger, it not just depends on the caller,
but it may depend on run-time events. Imagine something like the
following (with A and B classes as Paul described them):
def myFactoryFunction():
if randint(0, 1):
return A()
else:
return B()
if you then did:
x = myFactoryFunction()
x.bar()
which version of bar() should get called is truly random and only known
at run time.
More information about the Python-list
mailing list