> Well, this assumes automatic adaptation (which is off the table), *or* > everything that uses IFruits must always explicitly invoke some (...) > You've lost me here. A less abstract example might work better.
Sorry.. I should have provided a good concrete example in the first place. Here it goes. implements(Apple, IFruit) implements(Orange, IFruit) With adapters: registry = AdapterRegistry() registry.register(IFruit, IJuice, fruit_to_juice) registry.register(IFruit, IJelly, fruit_to_jelly) apple_juice = registry.query(apple, IJuice) orange_jelly = registry.query(orange, IJelly) With generic functions: @generic juice(obj): return None juice.register(IFruit)(fruit_to_juice) @generic jelly(obj): return None jelly.register(IFruit)(fruit_to_jelly) apple_juice = juice(apple) orange_jelly = jelly(orange) Notice the subtle difference between them. The "target" interface is gone with generic functions. Think of how both would be handled without interfaces. It can be done for sure, but interfaces do provide additional value. -- Gustavo Niemeyer http://niemeyer.net _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
