const warning...
Robert Dewar
dewar@gnat.com
Sat Jul 5 05:51:00 GMT 2003
> Adding "const" on local variable definitions that happen to only be set
> once is not especially useful for documentation or maintenance purposes.
I disagree strongly. The difference between constants and variables is
important and fundamental. One of the problems with C++ (and Ada for
that matter) is that they require extra syntax for constants which tends
to encourage the use of variables by default.
To require the complete elimination of variables from programs is a bit
extreme, though perfectly practical, but certainly minimizing the use
of variables is a generally reasonable programming practice, and for me
it very much helps reading the code to know that something is constant
and cannot change.
We have found the corresponding feature in GNAT, -gnatwk to be very useful.
More information about the Gcc
mailing list