[Types-sig] Interface PEP
Paul Prescod
paulp@ActiveState.com
Wed, 14 Mar 2001 22:36:00 -0800
Samuele, I agree with the vast majority of your analysis but I'm not
sure that the objects you call Protocol Domain Checkers and Interfaces
are necessarily distinct. An interface has two parts: there is the
"semantic" part that is checked only by human inspection and there is
the signature part that could, in theory, by checked by software at
runtime (or even compile time in some cases).
A "domain checker" inevitably also has a semantic part and an
operational part. The operational part also checks an object for
conformance to a set of rules. I don't see how the two things are very
different other than the syntax.
> * one can check wheter an input explicitly declare to implement an
> interface (interfaces could have their __implementedBy__)
I've come to think that there is a difference between what Michel calls
__implementedby__ and what I now call __check__ (as Tim H. called it
originally). Both of our models should support both methods. One checks
that an object CLAIMS to support an interface and the other checks that
it has the right signature.
> * ideally there could be a constructor that produce a protocol domain
> checker out of an interface:
> JustProtocol(FooInterface).__implementedBy__(baz):
> checks whether baz declares to implement FooInterface (this for speed),
> or checks wheter baz defines the methods required by FooInterface
I would write that as FooInterface.__check__(baz)
>...
> Note: protocols as intended do not form an explicit hierarchy, but there is an
> inclusion
> relation.
If you integrate protocols and interfaces then it makes sense for the
integrated thingee to have an hierarchy.
--
Take a recipe. Leave a recipe.
Python Cookbook! http://www.activestate.com/pythoncookbook