<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<blockquote TYPE=CITE> [Previous] [Next] [Reply]
[Index] [Home] [Find]
<p> * Newsgroups: comp.lang.python
<br> * From: qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk)
<br> * Subject: Re: PEP 245
<br> * Date: 1 Apr 2001 13:26:49 GMT
<br> * Organization: Klub Nieszkodliwych Manjaków
<p> ------------------------------------------------------------------------
<p>Sun, 1 Apr 2001 00:21:05 -0800 (PST), Alex Shindich <alex@server01.shindich.com>
pisze:
<p>> 1. What is the point of interfaces without static typing?
<p>To formalize requirements about objects.
<p>To get better error messages early, instead of cryptic errors raised
<br>deep where the object was finally actually used.</blockquote>
Try this:
<br>class MyInterface:
<br> def foo (self):
<br> """
<br> """
<br> raise UnimplementedMethodException
("Method foo is not implemented.")
<p>class ConcreteClass (MyInterface):
<br> ...
<blockquote TYPE=CITE>
<br>> There is no guarantee that method doSomething declared in the
<br>> interface has anything in common with the method doSomething declared
<br>> in the concrete implementation class.
<p>It cannot be guaranteed in general in any framework. But an interface
<br>implies some properties of its methods and objects should be declared
<br>as conforming to an interface only if their methods really have an
<br>appropriate meaning.</blockquote>
All it guarantees is that the concrete class has methods with the same
names as those in the interface.
<blockquote TYPE=CITE>> If the compliance is checked at run time, then
interface checking is
<br>> as good as as simply assuming that the method is implemented. Today,
<br>> I can compile code like "f.doSomething ()" without f actually
<br>> implementing doSomething. At run time I would get an AttributeError
<br>> thrown into my face.
<p>You may get the error too late or with unhelpful error message, and
<br>you won't get the error if the object happens to have a method of
<br>the given name but the method means a completely different thing.
<br>And you don't have a hint what objects a method expects nor what
<br>objects it returns, besides some informal explanation in docs.</blockquote>
Huh? What do doc strings have to do with this? Document your base classes,
and you will get the same amount of documentation.
<br>Also, how would error message like "InterfaceError: 'Foo' does not
implement method 'Bar'" be more helpful then "AttributeError: 'Foo' instance
has no attribute 'Bar'"?
<p>> 3. I am just curious... Does any one smell Java here?
<blockquote TYPE=CITE>
<br>I would prefer to discuss features themselves than to draw conclusions
<br>from similarities to other languages, especially languages we don't
like.</blockquote>
Hmm... I happened to like to Java... It's just that I use it when
I need strong typing. And I totally love Python, and I use it whenever
I can...
<blockquote TYPE=CITE>--
<br> __("< Marcin Kowalczyk * qrczak@knm.org.pl <a href="http://qrczak.ids.net.pl/">http://qrczak.ids.net.pl/</a>
<br> \__/
<br> ^^
SYGNATURA ZASTĘPCZA
<br>QRCZAK
<p> ------------------------------------------------------------------------
<br>Mailgate References:
<br> PEP 245, Alex Shindich
<br> ------------------------------------------------------------------------
<br> [Previous] [Next] [Reply]
[Index] [Home] [Find]
<br>Mailgate.ORG is maintained online by Dario Centofanti</blockquote>
<pre>--
Alex Shindich
<A HREF="mailto:alex@shindich.com">mailto:alex@shindich.com</A>
Visit <A HREF="http://www.shindich.com/">http://www.shindich.com/</A></pre>
</html>