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

Lindley French lindleyf at gmail.com
Sun Mar 9 19:28:26 CET 2014

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140309/ba7b63d7/attachment.htm>

More information about the zeromq-dev mailing list