On Thu, 21 Aug 2008 15:37:46 GMT, Juha Nieminen
<nospam@thanks.invalid> wrote:
puzzlecracker wrote:
I think void f(const int i) is plainly stupid....
Why? It documents that the parameter is not modified in the
program,
Yes, but callers couldn't care less -- which is why C++ allows this:
void f(int i); // interface
void f(const int i) // implementation, locks down 'i'
{ ... }
and additionally makes the compiler tell you if you break the
promise nevertheless. If it was not your intention to modify the
parameter (even though it's just a local copy), the compiler error
can hint you at your mistake.
Yes, I use that a lot, if the function is messy enough.
It can be useful to know that 'i' still has the same value
two pages down in the code ...
that the code is not really good enough.
function. :-)