This is not the same thing. The problem with the Go implementation is essentially that the method is semantically different from the expected method.
Closing a stream is semantically different from not closing a stream. It just is. The Go method was just wrong.
The problem was not the type introspection. There's nothing wrong with us attempting to do optimization for ICollection`1 or the rest of the collection interfaces because we have exactly the same semantic effect.
If you use different methods to achieve the same semantics, that's an implementation detail. If you use any methods to produce different semantics, that's a bug.
> This is not the same thing. The problem with the Go implementation is essentially that the method is semantically different from the expected method.
No-one is arguing about the Close() case. However, the io.Copy() case is comparable to the IEnumerable<T>.Count() implementation.
Unless your WriterTo method does something different than the caller assumes it's going to do.
Unless the special functions are predefined by the language (e.g. Python's __str__, __len__, __iter__, etc.) or specified in an interface that the class explicitly inherits from, making assumptions that the language developers and I meant the same thing is careless at best and dangerous at worst.
Closing a stream is semantically different from not closing a stream. It just is. The Go method was just wrong.
The problem was not the type introspection. There's nothing wrong with us attempting to do optimization for ICollection`1 or the rest of the collection interfaces because we have exactly the same semantic effect.
If you use different methods to achieve the same semantics, that's an implementation detail. If you use any methods to produce different semantics, that's a bug.