Re: const correctness
Dimitri Fontaine <dimitri@2ndquadrant.fr>
From: Dimitri Fontaine <dimitri@2ndQuadrant.fr>
To: "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Cc: "Tom Lane" <tgl@sss.pgh.pa.us>, "Robert Haas" <robertmhaas@gmail.com>, "Thomas Munro" <munro@ip9.org>, <pgsql-hackers@postgresql.org>
Date: 2011-11-09T22:08:26Z
Lists: 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