by jy3 · 9y ago · 0 comments
Who would have thought. Maybe a rewrite would have been more appropriate.
But I still ended up with the same classes replicated hundreds of times.
Polymorphic code is not possible in any other way in go – you always have to duplicate the code.
Your example intrigues me, isn't an interface enough?
Is what bother you that the return value won't be typed T but IIncrementable in go?
My system is usually designed that I provide a function that generates a value of type T, a function to filter T (T -> boolean), and a way to display Ts.
So, the library now gets these functions, and does all the filtering on other threads.
So either I have to replicate the entire async code for every type, or I can’t keep type safety.