5 ms·
I don't understand: what do you mean with binding methods to interfaces? Interfaces just represent a bunch of functions that an object must provide (and you ca
by dullgiulio 8y ago
I don't understand: what do you mean with binding methods to interfaces?
Interfaces just represent a bunch of functions that an object must provide (and you can call when you "mask" the object behind the interface).
- JepZ 8y agoWell, normally you bind functions to types like: func (m myType) calcRandom() int { return m.nine } But there are some situations when it would be useful to be able also bind functions to interfaces (e.g. some of them are similar to use-cases for abstract classes in OOP): func (i myInterface) calcRandom() int { return i.Nine() } While I would consider it a clean language design to be able to do that too, it brings some additional complexity and as we know Golang doesn't like complexity. As I said, I am not completely sure of the consequences such a change would bring with it and if it would enable bad practices. So I would not push too hard for that one, but some of the other issues I mentioned are issues of which I am pretty sure that they should be fixed.
- marcus_holmes 8y agoum.. I think you've confused the interface and the implementation. Interfaces are not the same thing as classes, and bringing anything from OOP to them will almost certainly result in Bad Things.