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

Pieter Hintjens ph at imatix.com
Sun Mar 9 20:31:24 CET 2014


I'll fix the obvious char * arguments at least...

On Sun, Mar 9, 2014 at 7:28 PM, Lindley French <lindleyf at gmail.com> wrote:
> Consistency is less important than correctness. If it doesn't make sense to
> make a FILE* const, then don't. The question should not be "is this
> completely consistent," but "is this function going to modify this
> parameter?". If the answer is no, and especially if it doesn't make sense
> for the parameter to be modifiable from an interface perspective, then const
> it.
>
>
> On Sat, Mar 8, 2014 at 6:40 PM, Pieter Hintjens <ph at imatix.com> wrote:
>>
>> On Sat, Mar 8, 2014 at 2:11 PM, Turkey Breast <turkeybreast at yahoo.com>
>> wrote:
>>
>> > Can you give an example where adding const would break a method for
>> > existing users?
>>
>> You're right. Adding const breaks code downstream, not upstream. As
>> Lindley says, the problem is when it's applied inconsistently
>> (annoying casting from const char * to char *).
>>
>> Adding const for all char * arguments (CZMQ never modifies char *
>> arguments) would be OK. It's still inconsistent with other pointer
>> arguments and IMO confusing (what does it mean to pass a "const FILE
>> *" argument, for instance?) But it'd be fine.
>>
>> -Pieter
>> _______________________________________________
>> 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
>



More information about the zeromq-dev mailing list