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.
Re:It is ridiculously easy to refactor Go
by plorkyeran on Sunday January 27, 2013 @06:02PM
(#5126058)
For runtime polymorphism you'd have to define a wrapper of some sort, which in this specific case would be completely trivial since it's only one method. In more complex cases it gets pretty awful compared to the Go version, but it's not impossible (although AFAIK if the methods you care about have different names in the different implementations you'll need a wrapper even in Go).
Re:It is ridiculously easy to refactor Go
by pdhborges on Sunday January 27, 2013 @05:33PM
(#5125959)
And he doesn't even have to define an interface.
Concepts were an attempt to allow people to explicitly state what that interface is: http://en.wikipedia.org/wiki/Concepts_(C%2B%2B)
(Please note I'm not saying this would be better, just pointing out that it's possible.)