El 9 Sep 2008, a las 20:37 , Dieter Maurer escribió:
Chris Withers wrote at 2008-9-8 18:34 +0100:
...
There's the backward-compatibility issue, which is a showstopper. There's plenty of code that does this:
adapter = package.interfaces.IFoo(object, None)
Changing the signature as you describe would break all code that does this.
How about a new major revision of zope.interface then?
I fear that would be a bit drastic -- for a mostly cosmetic change.
I agree.
But interfaces might grow an additional method, e.g. "adapt", which could get the new signature.
The syntax would be a bit more cumbersome -- but on the other hand, it would be more explicit :-)
I don't think it would be too cumbersome. While IMHO elegant, the current syntax of calling an interface to adapt isn't actually self- explanatory. I've frequently observed people tripping over this, specially when you have an IFoo interface and a Foo class -- which is quite common --, then IFoo(obj) and Foo(obj) differ only by one character. With your suggestion, it would be IFoo.adapt(obj) vs. Foo(obj), making the difference quite obvious. So overall I'm +1