logoalt Hacker News

quietbritishjim • today at 9:29 AM • 0 replies • view on HN

That doesn't work if your library needs to handle these events somehow, not just transparently pass them around.

Typically with your pattern, you'd use a switch statement on the event type, but what do you do if it's in the user-defined space (type>=EVENT_USER_START)? You could add mandatory function pointers for relevant handlers in a header prefix, but now you're just reimplementing virtual methods. As is common in C, you end up making your own object-oriented language, only with more effort and not as good.