[zeromq-dev] Questions about Coding Style
Mikko Koppanen
mikko at kuut.io
Sun Feb 12 22:40:10 CET 2012
On Sun, Feb 12, 2012 at 9:28 PM, Gary Wright <at2002+zmq at me.com> wrote:
> ruby client code => ruby binding => libzmq C binding => C++ core
>
> So I would just apply the principle described above to each interface.
>
> The C++ code should use error codes/exceptions according to C++ idioms.
> The libzmq C interface should translate C++ exceptions into error codes.
> A Ruby binding, for example, should translate some errors back into exceptions.
Hello,
I don't necessarily agree that the library code should take care of
validating every argument passed to it. In your example the ruby
binding should take care of the sanity of the arguments passed to
lower level or the ruby binding can be built on top of czmq, which
does more validation.
Adding more validation and cruft on the critical path means additional
CPU cycles wasted, which is not desirable in all cases. In my opinion
the raw library can and should assume that sane arguments are being
passed in and the higher level interfaces (czmq for example) can and
should do the validation on top of it if necessary.
-- Mikko
More information about the zeromq-dev
mailing list