[zeromq-dev] zmq_msg_init: suggest to change interface

john skaller skaller at users.sourceforge.net
Thu Jan 19 18:59:05 CET 2012


On 20/01/2012, at 4:28 AM, Chuck Remes wrote:

> It should just fail fast. If the unthinkable happens (zmq_msg_init fails), then the program should come down. It's clearly a *bug* somewhere, so the author should fix it.
> 
> Your philosophy may be different, but the fail-fast philosophy has worked pretty well for 0mq (grep the source base for "assert").

Agreed. I used assert to work around the problem.

By your philosophy, the assert should be in the implementation of zmq_msg_init,
which means it should return void. It can't fail in a recoverable way, so it should
handle any error itself (print diagnostic to stderr and exit or abort).

I mean, what else could the user possibly do? It can't be a programming error
in the user code. The only error the user could make is using an invalid
pointer, and that will cause a segfault or whatever anyhow.
And that's only in C. In any sane language the initialisation
will be done by the language system, the programmer isn't calling it at all.


--
john skaller
skaller at users.sourceforge.net







More information about the zeromq-dev mailing list