Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've written code just like this. Another option is to make the entire sort function a C macro. This would be feasible for something simple like quicksort.

But generics provide another benefit: in theory with them, the compiler should be able to determine that two high-level types are actually the same machine type, so in the above example, SORT_ELEMENT_TYPE int and long would not generate duplicate code on many machines.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: