| ▲ | nananana9 3 hours ago | |
It does.
That aside, have you ever felt the need to implement your own Win32 event, or SDL event, or X11 event, or epoll_event, or a custom DOM event or whatever?If you're writing a good library, give the user the data they need, and let them handle it however they wish, don't force them int your framework. | ||
| ▲ | quietbritishjim 2 hours ago | parent | next [-] | |
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. | ||
| ▲ | marckerbiquet 3 hours ago | parent | prev [-] | |
It does not work if two independent libraries depend on your library and create the same user EventType. | ||