[Zope3-dev] Proposal: Improving on __implements__

Jeffrey P Shell jeffrey@cuemedia.com
Sun, 19 Jan 2003 13:23:03 -0700


On Sunday, January 19, 2003, at 01:12  PM, Godefroid Chapelle wrote:

> At 16:08 19/01/2003, Phillip J. Eby wrote:
>>> I'd prefer to keep class statements as class statements. If Python 
>>> had an 'instances implement' statement that, for argument's sake is 
>>> 'implements', it might look like this:
>>>
>>>   class Foo:
>>>       implements IFoo, IBar
>>>
>>> So, I suppose I'm trying for something close to that, without 
>>> needing to change the language.
>>
>> Unfortunately, 'implements(IFoo,IBar)' doesn't look like a statement, 
>> it looks like a boolean test whose return value is being ignored.
>
> If a lurker can enter, I'd like to second Phillip on this opinion.

Note that in PEP 245's proposal, 'implements' would be a statement, but 
it would be part of the class statement itself:

class Foo implements (IFoo, IBar):
	...

which is how Java does it.  PEP 245 also adds a built in for 
implementation testing that is the boolean test:

 >>> myfoo = Foo()
 >>> implements(myfoo, IFoo)
True
 >>>

The PEP hasn't been accepted or rejected outright, and Guido's notes in 
the PEP Parade say thus:

> Jim Fulton has said that this PEP was premature.  I agree.  It 
> introduces a new keyword, 'interface', and I'm not yet convinced that 
> that is needed.  On the other hand, the way this is currently done in 
> Zope also looks butt-ugly, so something may indeed be needed.  I think 
> that at some point in the future when we have more experience with 
> using interfaces (especially in Zope 3) we'll go back to this PEP and 
> see how much of it we can use.  Maybe there should be a special status 
> "frozen" meaning not rejected but also not under consideration for the 
> near future?  But with a different meaning than Py-in-the-sky -- this 
> PEP at least has lots of concrete proposals and studies the 
> consequences.

http://www.python.org/peps/pep-0245.html
http://www.python.org/doc/essays/pepparade.html

--
Jeffrey P Shell
jeffrey@cuemedia.com