News for hackers. Stuff that matters.
Re:It is ridiculously easy to refactor Go by bslatkin on Sunday January 27, 2013 @09:35PM (#5126787)
Yes, it's possible to use C++ templates to accomplish this. But you'd still miss other features because the types of Header and MIMEHeader are not actually unified. Go would let you statically type-check at compile time, but also understand those types are the same (as "emailHeader") at runtime, so you could do this:

x := ... // Header, MIMEHeader, or whatever you want v, ok := x.(emailHeader) if !ok { fmt.Println("It's not compatible with Get(string) -> string") }

So, it's a nice mix of static and dynamic typing.

(ps: http://golang.org/ref/spec#Type_assertions)

There are no comments on this comment yet.