2 ms·
Ah, I see what you mean. You can see this issue in action in Go's math package, where "Min" is defined on only float64. I was lumping this in under the general
by fixermark 11y ago
Ah, I see what you mean. You can see this issue in action in Go's math package, where "Min" is defined on only float64.
I was lumping this in under the general category of the "Go has no generics" issue; without generics, Go can't do this anyway (and the closest solution you would have would be to define an interface Algebraic that specifies functions algebraic types need to support, then implement operations like min and average atop those interfaces). I'm still of the personal opinion that (as other commenters noted) what you gain in being able to define operator+ you lose in boost developers getting clever and implementing operator/= on paths; even if we had generics, I'd personally find a Go-like solution of declaring the function package an algebraic type had to support (via an Interface) preferable.