2 ms·
> Polymorphism is doable in plain old C with lookup tables and function pointers Not without casting. qsort is still: void qsort_r(void *base, size_t nme
by mrkeen 3y ago
> Polymorphism is doable in plain old C with lookup tables and function pointers
Not without casting. qsort is still:
void qsort_r(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *, void *),
void *arg);
- chuckadams 3y agoPresumably one would write an object-oriented version of quicksort to go with their OO C library design and not use the stdlib functions. For example GObject is OOP in C, and I imagine it has collection types with sort methods. Inheritance is what will bite hard when hand-rolling OOP in C. For one, you can forget about the compiler enforcing substitutability and co/contravariance for you.