5 ms·
I'm a bit surprised by the comments here. Isn't this just duck typing, which has been a thing in dynamic languages for a very long time? The supposed risks of
by beart 2y ago
I'm a bit surprised by the comments here. Isn't this just duck typing, which has been a thing in dynamic languages for a very long time?
The supposed risks of breaking the contract by changing the class ring hollow to me. The implicit interface you have created is already public. So how is that any different than changing any other public API? There is no suggestion of an implicit interface over private methods.
I've worked in c# and typescript. I don't think this feature is particularly needed in c#, but I also don't see the issues presented by other comments as real problems.
- 8n4vidtmkvmk 2y agoWhat about methods that share a signature but have a different meaning? The interface can have a comment documenting what it's supposed to do. Any class/function that explicitly implements said interface should adhere to that definition/meaning. Any function that implicitly implements it... who knows what was intended.
- beart 2y agoIn theory, you have a point. However, in practice it doesn't matter. It is extremely unlikely that the code is written in a way where random, unknown implementations are being passed around and called.