4 ms·
The lack of generics for C makes it difficult to write those sorts of libraries in an efficient way.
by lalaland1125 5y ago
The lack of generics for C makes it difficult to write those sorts of libraries in an efficient way.
- ncmncm 5y agoAnd, generally impossible to write C generics so they may confidently be used safely. There are reasons why C++ was necessary.
- klyrs 5y agoC has had generics since C11. Can't fault you for not knowing that, as they're a pain to use and I think folks would rather forget that the language feature exists.
- edflsafoiewq 5y ago_Generic is basically a switch on typeof(x). Despite the name, it's really a specialization/overloading mechanism.
- junon 5y agoThose aren't generics, they're more like overloading.
- rwmj 5y agoI wrote this (slightly crazy) generic vector for C: https://gitlab.com/nbdkit/nbdkit/-/blob/master/common/utils/vector.h https://gitlab.com/nbdkit/nbdkit/-/blob/master/common/utils/... If you search for "string" in this page you can see how it is used: https://gitlab.com/nbdkit/nbdkit/-/blob/master/plugins/data/format.c https://gitlab.com/nbdkit/nbdkit/-/blob/master/plugins/data/...
- tekknik 5y agoYou’d use a code generator for this, similar to how you’d do it in golang.