Re: Coding style point: "const" in function parameter declarations

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Dan Ports <drkp(at)csail(dot)mit(dot)edu>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Coding style point: "const" in function parameter declarations
Date: 2011-06-22 16:24:42
Message-ID: BANLkTi=MEtaYnH7DqRva=9Dqoq_FyeZ7=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 21, 2011 at 5:51 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Declarations like "const structtype *param" are fine, because those
> create a real, enforced contract on what the function can do to data
> that is visible to its caller.  But I don't see any value at all in
> const-ifying the parameter itself.
>
> Comments?

What about making a separate typedef for that (like ConstRelation)?
Maybe the const contract is useful, and aren't there occasional
performance enhancements the compiler can make when it function
arguments are const?

merlin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2011-06-22 16:26:42 Re: Repeated PredicateLockRelation calls during seqscan
Previous Message Kevin Grittner 2011-06-22 16:06:06 Re: Coding style point: "const" in function parameter declarations