[zeromq-dev] why do czmq methods take a char* parameter and not const char*?

Laurent Alebarde l.alebarde at free.fr
Sat Mar 8 10:16:13 CET 2014


Software is not about what's one likes or not, but about standards, 
state of the art, rigorousness, and quality.

/Simplicity/ does not go always along /quality/, but /quality/ goes far 
much often with /simplicity/.

IMHO, if the libzmq code was much quality and standards oriented, it 
would be simplier.

Le 08/03/2014 08:38, Pieter Hintjens a écrit :
> The lack of consts in the CZMQ API is my fault. I don't like consts in
> C development; they add complexity for little (in my experience)
> benefit.
>
> Changing CZMQ now would break existing applications. I'd actually like
> to remove consts where they are, to get consistency and make the APIs
> more simple.
>
> I'd just add the casts on top. It's in a wrapper and invisible to
> application code. Will that work?
>
>
> On Sat, Mar 8, 2014 at 4:55 AM, Turkey Breast <turkeybreast at yahoo.com> wrote:
>> Not all the methods are consistent. zsockopt and zstr use const char* while zsocket, zcert and zauth use char*.
>>
>>
>>
>>
>>
>> On , Turkey Breast <turkeybreast at yahoo.com> wrote:
>> Would you accept such a patch?
>>
>>
>>
>>
>>
>>
>> On , Turkey Breast <turkeybreast at yahoo.com> wrote:
>> My custom wrapper:
>>
>> https://github.com/darkwallet/czmqpp
>>
>> See this file:
>>
>> https://github.com/darkwallet/czmqpp/blob/master/src/authenticator.cpp
>>
>> I'm not even sure if what I'm doing is right. Does ZMQ modify those buffers at all? If so, why? Otherwise if they're just lacking const qualifiers, I'd rather not needlessly copy buffers. Would make sense to add them to czmq if possible.
>>
>>
>>
>>
>>
>>
>> On Saturday, March 8, 2014 2:56 AM, Turkey Breast <turkeybreast at yahoo.com> wrote:
>> I'm writing a c++ wrapper and this causes problems because a) string constants casting to char* is discouraged b) const char* std::string::c_str() needs a const_cast<char*> which is dodgy.
>>
>> Is there any chance to make some of these methods with const char* instead?
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140308/9da1ec84/attachment.htm>


More information about the zeromq-dev mailing list