News for hackers. Stuff that matters.
Re:The ups of downs of porting 50k lines of C++ to Go by gnuvince on Saturday March 07, 2015 @10:31AM (#9161985)
No, what he means is the you would need to write these two functions:

        func DotProductInt(v1, v2 Vector2D) int {
             return v1.x*v2.x + v1.y*v2.y
        }

        func DotProductFloat(v1, v2 Vector2DFloat) float64 {
             return v1.x*v2.x + v1.y*v2.y
        }
If Go allowed for parametric polymorphism, the type of the elements could be abstracted away like this (not real syntax obviously)

        type Vector2D<t> struct {
             x, y t
        }

        func DotProduct(v1, v2 Vector2D<t>) t {
             return v1.x*v2.x + v1.y*v2.y
        }

There are no comments on this comment yet.