Re: const correctness - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: const correctness
Date
Msg-id m2fwhxj6ed.fsf@2ndQuadrant.fr
Whole thread Raw
In response to Re: const correctness  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-hackers
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
>> In C, the impedance match is a lot worse, so you have to pick and
>> choose where const is worth the trouble.
>  
> Agreed.  And I'm not sure how much of what Thomas is proposing is
> worth it; it just seems prudent to consider it while the offer is
> being made to do the work.

If the gain is for human readers of the API rather than the compiler and
some level of automated checking, what about this trick:

#define constp

Then you can use it wherever you want to instruct readers that the
parameter is a constant, it's now a noise word as far as the compiler is
concerned (thanks to the precompiler replacing it with an empty string).

Regards,
-- 
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: heap vacuum & cleanup locks
Next
From: Tom Lane
Date:
Subject: Re: Cost estimates for parameterized paths