4 ms·
I repeatedly see this point re: implicit interfaces, and yet it’s never accompanied by an explanation of its actual benefits. The one defense I’ve heard is tha
by stouset 9y ago
I repeatedly see this point re: implicit interfaces, and yet it’s never accompanied by an explanation of its actual benefits.
The one defense I’ve heard is that it allows you to define interfaces that are implemented by types you don’t control, but this completely ignores the fact that doing so implicitly isn’t necessary for such a feature, and other languages (e.g., Rust) elegantly demonstrate why that is.
- bunderbunder 9y agoI'd go one further and say that the way other languages do it does a better job of letting you define interfaces for types you don't control. Sometimes the type you want to apply your interface/trait to doesn't have a function that does what you need, but could easily be assembled from other members of the type. And sometimes it does have a function that would work, except that the name is different. There's an Uncle Bob talk I watched a while back where he suggests that oftentimes language designers will say just about anything to avoid admitting that the real reason a feature is absent or was implemented in a hacky way is for the convenience of the compiler's authors.