Re: gratuitous casting away const

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mark Dilger <hornschnorter(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: gratuitous casting away const
Date: 2016-09-22 16:14:43
Message-ID: 26710.1474560883@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Mark Dilger <hornschnorter(at)gmail(dot)com> writes:
>> On Sep 20, 2016, at 1:06 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> ... that seems to be discarding type information in order to add
>> "const"; does not seem like a net benefit from here.

> The following seems somewhere in between, with ItemPointer
> changing to const ItemPointerData *. I expect you would not care
> for this change, but thought I'd check to see where you draw the line:

I'd call this kind of a wash, I guess. I'd be more excited about it if
the change allowed removal of an actual cast-away-of-constness somewhere.

I suppose it's a bit of a chicken and egg situation, in that the lack
of const markings on leaf subroutines discourages use of "const" in
callers, and you have to start somewhere if you want to make it better.
But I don't really want to just plaster "const" onto individual functions
without some larger vision of where we're going and which code is going
to benefit. Otherwise it seems like mostly just code churn.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-09-22 16:32:00 Re: 9.6 TAP tests and extensions
Previous Message Tom Lane 2016-09-22 15:52:39 Re: ICU integration