3 ms·
Generics alone wouldn't be sufficient to replace the code generator, you'd also need specialization and/or overloading, or at least some significantly different
by morelisp 5y ago
Generics 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.