Paul Eggert wrote: > I agree with Bruno on this point. It's hard enough to read C code > without having to wade through all those 'const's on local variables.
Hi Paul, By "local variables" you must mean "local scalar variables". You wouldn't argue for dropping "const" as a pointer attribute. > The tiny extra benefit that they provide is not worth the overhead on > people trying to read the code. What's next? Should we also add > 'const' to parameter declarations? (And if not, why not?) > > All other things being equal, we should be encouraging a functional > style in which most local variables and parameters are never modified > once set. Requiring or encouraging programmers to add these 'const's > works against this goal, and makes code harder to read and maintain. I'm not in the habit of using "const" on scalars. Inserting the "const" on each line before the "bool" in that example did make me think twice: putting it before the type makes the type name less apparent, and putting it after the name cannot be justified like it can for a pointer. It wasn't terribly fulfilling, but that function is so small I'm not convinced it's even worth the trouble of reverting the change. In any case, don't worry: I'm not about to add "const" to all scalar declarations.