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

I've never heard anyone describe function pointers as meta-programming before.

Functions are data, just like other kinds of data. I use them in C whenever what I want to parameterize is behavior, and not, say, an integer or a string.

I believe that if you explicitly avoid function pointers, and instead use a less appropriate construct, that would become a mess, instead. If you replace the function pointer with an enum, you've tightly coupled the type definition of the parameter with all users. You've added a switch statement on the enum, rather than a function pointer call. It would be both messier and probably slower than the function pointer.



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

Search: