PEP 245

Carlos Alberto Reis Ribeiro cribeiro at mail.inet.com.br
Sun Apr 1 12:36:13 EDT 2001


At 00:21 01/04/01 -0800, Alex Shindich wrote:
>I know I am going to get hate mail for this, but I have to get it off my
>chest!

The list is getting tougher as of late..

>1. What is the point of interfaces without static typing?

I'm not the best person to answer you, but that's my take. Interfaces allow 
for some very powerful forms of OO abstraction to be implemented. You 
aren't forced to use inheritance for everything. This frees the class 
hierarchies, making it possible to have a "mesh" of classes instead of a 
very rigid tree structure. It also tends to minimize the use of multiple 
inheritance, when all that you want is to support multiple interfaces. All 
of this is possible even without static typing. As for your concern with 
the semantics, no strongly typed language can enforce it - you have just to 
hope that the function being called behaves as documented.

>2. At what point will the compliance with the interface definition be
>done, at compile time, or at run time?

Don't know what the dev guys are thinking. I would prefer *not* to 
explicitly check interface compliance at any time. You said that you 
supported a interface, it's your job to write the methods for it. If you 
don't do so, you get an exception.

>Also, will it be possible to instantiate classes that do not implement all
>the interface methods?

I think so, mostly because doing things at compile time is not Python's way 
of doing things. May be the class wass defined as supporting a interface 
and a method is missing. Maybe the method is not really needed in some 
particular context; that's a risky assumption, but only the developer can 
tell if it's ok. Maybe the method is going to be "attached" to the class 
afterwards. Maybe you end up using some hack with __getattr__ to support 
it. In my opinion, the bytecode compiler should not check this kind of stuff.

>3. I am just curious... Does any one smell Java here?

Java, Python, Jython... no, I'm joking. But I think that is reasonable for 
any language developer to borrow stuff from other languages. People has 
been doing this for a long time anyway <wink>. Also note that, by 
supporting a runtime (on-demand) approach to interface checking, we are 
keeping with Python tradition.


Carlos Ribeiro






More information about the Python-list mailing list