3 ms·
Go is a great language, reading the code in this PR is so easy
by Shadonototra 5y ago
Go is a great language, reading the code in this PR is so easy
- kevincox 5y agoOn the other hand without generics they are literally using a text templating language to generate the code.
- morelisp 5y agoGenerics alone wouldn't be sufficient to replace the code generator, you'd also need specialization and/or overloading, or at least some significantly different syntax allowed for comparing primitive types.
- kevincox 5y agoI think it probably would in this case. They appear to be substituting just a comparison function. They could instead take a generic type argument that had the desired functions defined. Then you would just need to write the top level wrappers with the different names. In fact they could probably have done this with a traditional Go interface if they weren't worried about missed optimizations.
- deleted 5y ago[deleted]
- yencabulator 5y agoI fear the generic version would miss on those same optimizations, and that is the real reason it's written like it is. Remember, Go generics use gcshape stenciling, not C++ style templates.
- icholy 5y agoI believe OP is being sarcastic.