3 ms·
You don't mention your level of experience with generic type systems, but I find it's mostly the case that I can't imagine any use for techniques I'm not yet fa
by andreasgonewild 9y ago
You don't mention your level of experience with generic type systems, but I find it's mostly the case that I can't imagine any use for techniques I'm not yet familiar with.
Here is a random example from my recent adventures, a channel implementation in C++ which uses generics to provide value-semantics for user-specified message types:
https://github.com/andreas-gone-wild/snackis/blob/master/src/snackis/core/chan.hpp https://github.com/andreas-gone-wild/snackis/blob/master/src...
And here is a column class that uses generics to inject both record type and value type into the implementation:
https://github.com/andreas-gone-wild/snackis/blob/master/src/snackis/db/col.hpp https://github.com/andreas-gone-wild/snackis/blob/master/src...
Doing any of these without generics would mean either erasing types or writing duplicate code. Go provides generic channels, slices and maps; but it doesn't extend that power to user-code since users are supposedly not smart enough to be trusted with power.