
Dec. 30, 2012
9:28 p.m.
On 12/30/2012 10:05 AM, Nick Coghlan wrote:
The general problem with adding new methods to types rather than adding new functions+protocols is that it breaks ducktyping. We can mitigate that now by adding the new methods to collections.abc.Sequence, but it remains the case that relying on these methods being present rather than using the functional equivalent will needlessly couple your code to the underlying sequence implementation (since not all sequences inherit from the ABC, some are just registered).
You know what wouldn't break duck typing? Adding an extension-method-like (a la C#) mechanism to ABCs. Of course, the problem with that is, what if a sequence implements a method called replace that does something else?