This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: const warning...


> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]