|
|
|
|
|
by coldtea
3992 days ago
|
|
>* I wonder if "generics + traits" (where C++ is trying to go) is essentially the same as "no generics + interfaces" (Go's version of the same thing, maybe?)* It's the same end result, but without the speed and the type checking of proper Generics. (Assuming you mean "empty interfaces" (interface{}). Else, regular interfaces are not the same thing as Generics. >On reflection, "traits" is probably the wrong word. C++ has a word for this, but I'm drawing a blank at the moment. Templates? |
|
Now, in Go, you don't have generics. But you can have a sort function that takes a type (interface) that means "something that has a less-than function", and because of the way Go does OO, anything that has that function works.
This doesn't get Go to the point of having templates that will take any type whatsoever (unless you use empty interfaces).
I feel like I'm still using the wrong word in one or two places. But I hope this is more clear than my previous comment.