Hey, Chris McDonough wrote: [snip] > If you want to create a world where callers never need to care about the > lifetime of any object returned by a component lookup, you could also return > a > proxy wrapper around the returned object that only allows for the invocation > of > the methods defined in the interface looked up. Any other access or > invocation > would raise an exception. > > This would make this worldview 100% consistent, completely documentable, and > would cause no confusion during use. It would thus remove any logical > argument > I have against it. I wouldn't be eager to use such a system, but it's > totally > consistent.
In the Python world interfaces aren't enforced on the language level. But we all know that the programmer better beware and follow the implicit API anyway. With zope.interface, we have a tool to make that implicit interface explicit. Static type advocates argue that if you actually shouldn't cheat anyway, you should have the language help you in verifying that what you're doing is correct. Dynamic type advocates argue that the developer overhead of typical statically typed languages is so big that we'd rather have a bit more danger. And sometimes being able to cheat and get away with it is darn convenient. We happen to be using a dynamically typed language. I don't understand why this particular situation is so unique that this would require a proxy that raises exceptions. If you follow that reasoning, you could just as well say the only sane way to use methods in Python is to require proxies that raise exceptions around method arguments if the input doesn't provide the right interface. Regards, Martijn _______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )