The term "Protocol"

Bruce Eckel BruceEckel at MailBlocks.com
Wed Aug 4 20:46:23 CEST 2004



Monday, August 2, 2004, 8:44:38 AM, Aahz wrote:

> Alex Martelli gave an excellent presentation on Design Patterns at OSCON,
> where he made the point that "interface" is roughly equivalent to syntax,
> whereas "protocol" is roughly equivalent to syntax plus semantics.  In
> other words, computer langauges rarely (if ever -- although I suppose
> Eiffel comes close) enforce protocols in any meaningful way.

But what would the syntax be in Python? -- there is none. Perhaps you
mean that in Java a protocol would be an interface plus agreed-upon
semantics, whereas in Python the protocol would be the agreed-upon
(e.g. "latent") interface plus the agreed-upon semantics. In a sense,
both the syntax and semantics would be latent; they would only be
exposed and tested during use, since there is no formalized way to
define them.

In Python, of course, you could simply use a class with "pass" methods
everywhere to define a protocol. If there were some way to write
assertions about the protocol you could include those in the class.

Bruce Eckel





More information about the Python-list mailing list