At 02:27 PM 1/12/05 +0000, Mark Russell wrote:
I strongly prefer *not* to have A->B and B->C automatically used to
construct A->C.  Explicit is better than implicit, if in doubt don't
guess, etc etc.

So I'd support:

    - As a first cut, no automatic transitive adaptation

- Later, and only if experience shows there's a need for it,

Well, by the experience of the people who use it, there is a need, so it's already "later". :) And at least my experience *also* shows that transitive interface inheritance with adaptation is much easier to accidentally screw up than transitive adapter composition -- despite the fact that nobody objects to the former.


But if you'd like to compare the two approaches pragmatically, try using both zope.interface and PyProtocols, and see what sort of issues you run into. They have pretty much identical interface syntax, and you can use the PyProtocols declaration API and 'adapt' function to do interface declarations for either Zope interfaces or PyProtocols interfaces -- and the adaptation semantics follow Zope if you're using Zope interfaces. So, you can literally flip between the two by changing where you import the 'Interface' class from.

Both Zope and PyProtocols support the previous draft of PEP 246; the new draft adds only two new features:

* Ability for a class to opt out of the 'isinstance()' check for a base class (i.e., for a class to say it's not substitutable for its base class, for Alex's "private inheritance" use case)

* Ability to have a global type->protocol adapter registry

Anyway, I'm honestly curious as to whether anybody can find a real situation where transitive adapter composition is an *actual* problem, as opposed to a theoretical one. I've heard a lot of people talk about what a bad idea it is, but I haven't heard any of them say they actually tried it. Conversely, I've also heard from people who *have* tried it, and liked it. However, at this point I have no way to know if this dichotomy is just a reflection of the fact that people who don't like the idea don't try it, and the people who either like the idea or don't care are open to trying it.

The other thing that really blows my mind is that the people who object to the idea don't get that transitive interface inheritance can produce the exact same problem, and it's more likely to happen in actual *practice*, than it is in theory.

As for the issue of what should and shouldn't exist in Python, it doesn't really matter; PEP 246 doesn't (and can't!) *prohibit* transitive adaptation. However, I do strongly object to the spreading of theoretical FUD about a practical, useful technique, much as I would object to people saying that "using significant whitespace is braindead" who had never tried actually using Python. The theoretical problems with transitive adapter composition are in my experience just as rare as whitespace-eating nanoviruses from outer space.


_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to