[zeromq-dev] zeromq, abort(), and high reliability environments
michi at triodia.com
Thu Aug 14 12:22:18 CEST 2014
> On that note: Why is zmq using "void *" instead of declaring abstract
> types? If A context where a context_t and a socket a socket_t then
> even in C you couldn't accidentally pass a context in place of a
> socket. And yes, I've passed the wrong thing to zmq in C by accident
> because I got the argument order wrong and both values where "void *".
> No compiler warning or error. It just fails at runtime.
I've been puzzled by that one too. A pointer to an opaque struct would eliminate a lot of errors at compile time.
> Many languages also allow using them interactively. For example I can
> start an ocaml toplevel and then interactively enter commands to
> quickly try out stuff. But as soon as I type in the wrong thing libzmq
> would abort the whole session, loosing all the work entered before. An
> error or exception is far better there since the toplevel will catch
> that, display it and continue.
Well, I guess we are agreeing with each other :-)
That said, I can live with the aborts and the weak type checking, mainly because it's not too difficult for me to structure my code such that these errors become impossible. I'm more concerned about the policy angle. A general-purpose library shouldn't set policy, but a special-purpose library *should*. Zmq is a general-purpose library, and I don't think it's great to have it impose its view of "how things are done right" on every caller. I've written about this before:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the zeromq-dev