3 ms·
This is nice, but generic functions are still generics.
by catnaroek 10y ago
This is nice, but generic functions are still generics.
- spriggan3 10y agoGo already has generic functions : append, copy ... that are type safe at compile time, how do you think they are implemented in the source code of Go's compiler? Just like I said. Go compiler finds "append" token, and go look up if both arguments and the return type match, not at run time, at compile time.
- catnaroek 10y agoNo disagreement. I was just pointing out that what you were asking for is in fact user-defined generics.
- scott_s 10y agoIn fact, if I understand spriggan3's proposal correctly, that's how Java's generics work. The approach is usually called type-erasure. (https://docs.oracle.com/javase/tutorial/java/generics/erasure.html https://docs.oracle.com/javase/tutorial/java/generics/erasur...)