[Python-3000] Sane transitive adaptation

Phillip J. Eby pje at telecommunity.com
Thu Apr 6 18:44:38 CEST 2006


At 08:51 AM 4/6/2006, Nick Coghlan <ncoghlan at iinet.net.au> wrote:
>There is, however, an alternative, which would be to include a mechanism for
>telling a protocol about other equivalent protocols, and updating the
>registration mechanism to distribute any registration updates to the
>equivalent protocols.

I don't want to discourage people from working out their own ideas, 
but a lot of the stuff that's being discussed here about protocol 
adaptation is already implemented in PyProtocols.  For example, what 
you just described is called "implication" in PyProtocols: one 
protocol can "imply" another by way of an adapter, and in the 
equivalence case, the adapter is a special adapter called 
NO_ADAPTER_NEEDED.  So, your concept of equivalence is a subset of 
PyProtocols' concept of "implication".

Indeed, many other proposals that have been made here regarding 
protocol objects as registries, callable protools that adapt to 
themselves, etc. are all already implemented in PyProtocols, often in 
ways not too different from the sample code that people have posted 
with their proposals, except that PyProtocols handles a lot of edge 
cases and quirks (e.g. classic class issues, weak references, 
metaclass level issues, etc.) that you'd only know about from 
actually trying to use them.

Sadly, I believe one of the main reasons PyProtocols didn't get much 
uptake is simply that I wrote the documentation with *this* audience 
in mind: that is, people who want to develop a protocol/adaptation 
system.  Thus, I documented the metasystem and tradeoffs in the 
design of such a system, rather than putting much emphasis on the 
uses of adaptation.  So the PyProtocols docs suck -- unless you're 
trying to design or develop an adaptation system, that is.  :)




More information about the Python-3000 mailing list