Hacker News new | ask | show | jobs
by swisniewski 700 days ago
Extension methods complicate implicit interfaces considerably.

This is likely one of the reason they don’t exist in C#.

It’s also one of the reasons GO doesn’t have extension methods.

https://github.com/golang/go/issues/37742#issuecomment-59616...

You either have to exclude extension methods from implicit interface definitions (which can feel very unnatural to consumers) or you get weird behavior with dynamic casts that is very confusing and breaks everything.

For that reason, its unlikely you would see this in C#.

VB tried to do this (implement both extension methods and dynamic interfaces), and ended up cutting dynamic interfaces because the two features don’t play well together.

They are an awesome feature in GO, but it’s hard to add them to C# without a whole lot of very messy design compromises that make it kind of wonky.

If you eliminate extension methods it’s much easier to add dynamic interfaces.