This is the mail archive of the
mailing list for the GCC project.
Re: const warning...
- From: dewar at gnat dot com (Robert Dewar)
- To: Theodore dot Papadopoulo at sophia dot inria dot fr, fjh at cs dot mu dot OZ dot AU
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 5 Jul 2003 01:35:40 -0400 (EDT)
- Subject: 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.