This is the mail archive of the
mailing list for the GCC project.
Re: const warning...
On Mon, 2003-07-07 at 10:15, Gabriel Dos Reis wrote:
> Laurent GUERBY <firstname.lastname@example.org> writes:
> | On a 5 lines subprogram it doesn't make a difference, on a 100 lines
> | one with a dozen of declarations, it makes a huge difference if
> | 90% of those are marked constant and put in their proper scope.
> I don't know how const works in Ada, but I do know for sure that
> const-correctness *is* a source of problems in C++. Once you start
> putting const everywhere just because a variable happened not to be
> "apparaantly" changed, you might find yourself getting into trouble.
> People make living business writing series of books on the topic of
> const-correctness in C++.
Wow :). I must admit I don't see where the problem could come from,
procedure arguments in Ada are "const" by default, and most Ada code
I've seen use constant for local variables when it's appropriate,
nothing difficult and no black art.
A nice properties of for loop in Ada is that the
index is constant within the loop body:
for I in 1 .. 10 loop
I := I + 1; -- Illegal, I is constant within the body of the loop