From: Peter C. Chapin on
Seungbeom Kim wrote:

> I was saying that I was a bit hesitant to add or remove
> const depending on the implementation detail. Even though it does not
> affect the interface. Perhaps it's because, though const in the
> parameters for a function definition belongs to the realm of
> implementation detail, it doesn't look so or feel so; it is not buried
> in the function body but stands out too much in the declaration line.

Yes, I can see what you mean here. Declaring function parameters const does
make the const look more significant than it is. I suppose it's a
quirk(?) of
the way C++ is defined. I know that in Ada, for example, "in parameters" are
automatically treated as constants in the subprogram body. If you want to
modify them you have to make a copy of them.

> In addition, the simpler the function is, the more cluttered it makes
> the function to add const, and the less useful.

I agree that the usefulness of the practice diminishes as the functions get
simpler. With that in mind one might say that any function complicated
enough
to benefit from aggressive local const declarations is too complicated and
should be split into smaller functions. I could probably be sold on that.

Peter


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]