Re: Add some const decorations to prototypes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add some const decorations to prototypes
Date: 2017-11-03 17:54:30
Message-ID: 4767.1509731670@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
> On 10/31/17 10:56, Tom Lane wrote:
>>> Some functions have a strtol()-like behavior
>>> where they take in a const char * and return a pointer into that as
>>> another argument. In those cases, I added a cast or two.

>> ... but I'm not sure that it's an improvement in cases where you have to
>> cast away the const somewhere else. I realize that strtol has an ancient
>> pedigree, but I do not think it's very good design.

> Would you prefer leaving the input argument as char *, or change the
> endptr argument to const as well?

Just leave it as char*. If you change the endptr argument you're going to
force every call site to change their return variable, and some of them
would end up having to cast away the const on their end.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2017-11-03 17:55:03 Re: Dynamic result sets from procedures
Previous Message Peter Eisentraut 2017-11-03 17:50:28 Re: Dynamic result sets from procedures