One of the best type features of Go is the lack of need to do something like this: "@implements(IEatable)". If a class implements all of the methods of the interface, then it automatically implements that interface. Yuppy seems like a step backwards in OO in this regard.
Is it possible to indicate, in an interface, that it's not a structural type? Ie, that classes need to specifically indicate they implement it to be considered it's type?
For example, the HtmlString interface could require only "toString" as a method, but not everything that has that method should be considered that type.
Perhaps this is an unpopular opinion, but I think the Duck typing philosophy of Python is a feature, not a bug. Imposing the verbosity and rigidity of Java-style OO onto Python seems like a step backwards to me.
I feel like one of the merits of python is the looseness of classes and multiple inheritance. You get the benefits of OO without some of the pitfalls. Sure, you can go through the effort of defining an abstract class but it often isn't needed since your object is often composed of a bunch of separate objects - dealing with a formal contract to some 'abstract' version of your object just adds boilerplate and ends up creating convoluted class hierarchies.
This is very reminiscent of zope.interface used in Twisted. I wouldn't want to argue for or against it, but I've had times when something like this might have been useful in large code bases.
It would be very helpful to add to the README a section explaining what problems this solves. So examples of conventional python classes exhibiting weaknesses that are improved by using yuppy features.
But either way, you're going to get a runtime error. Languages like Java or C# that actually have real interfaces and abstract classes can detect these problems at compile time. This seems only marginally better.
jmpeax|11 years ago
RHSeeger|11 years ago
For example, the HtmlString interface could require only "toString" as a method, but not everything that has that method should be considered that type.
X-Istence|11 years ago
asdfologist|11 years ago
siliconc0w|11 years ago
dsymonds|11 years ago
Myrmornis|11 years ago
No, it isn't.
https://github.com/kuujo/yuppy/blob/master/yuppy/core.py
https://github.com/kuujo/yuppy/blob/master/tests.py
What you say is kind of funny, although rather an obvious sort of caustic witticism. But I think the answer is in fact obvious to you.
woadwarrior01|11 years ago
[1]: http://docs.zope.org/zope.interface/ [2]: http://twistedmatrix.com/documents/14.0.0/core/howto/compone...
Myrmornis|11 years ago
TTPrograms|11 years ago
aeflash|11 years ago
X-Istence|11 years ago