3 ms·
This is the API: int moustique_listen(const char* port, G closed_connection_handler, H data_handler); int moustique_list
by petters 9y ago
This is the API:
int moustique_listen(const char* port,
G closed_connection_handler,
H data_handler);
int moustique_listen(int listen_fd,
G closed_connection_handler,
H data_handler);
This could be improved, because the port argument could easily be confused with the file argument.
I.e.: moustique_listen(80, ...)
- Koshkin 9y ago> moustique_listen What, no love for namespaces?
- wyldfire 9y agoIt looks to me like this was by design. Several items are behind an 'namespace moustique_impl'.
- matt42 9y agoI did it this way because This library contains just one function. Would you still use namespaces in this case?
- Koshkin 9y agoWhy not? (An API is an API, no matter how many functions.)
- w8rbt 9y agoIt's just more C++ ish to write something::listen rather than something_listen. Namespaces are easy too. Why not?
- matt42 9y agoMy fear with this approach that it allows to write "using namespace moustique". This would cause: - name conflicts on the listen function. - Code harder to read since it's not obvious anymore that listen comes for the moustique library. I often use namespaces but I do think that they can have a bad impact on the usability of the api, especially when you have too many deeply nested namespaces, and have to use plenty on using namespace ... to fix this.
- RotsiserMho 9y agoI would. Both because it's more idiomatic and because it's inevitable more functions will be added.