Whether a parameter in a prototype is const or not makes no difference whatsoever. Not to the compiler, not to someone trying to use your function or reading your code. So having it there only makes things less clear, since it's not customary and it might lead someone to believe it means something.
The way I program, most of my local variables are initialized when they are defined and their values never change, so I could make them all `const', and the compiler would tell me if I am accidentally changing one. But this is very rarely a mistake I make, and the overabundance of `const's would clutter the code and make it harder to read, so I don't do it.
If I were designing the language, perhaps I would make the default be `const' and you would have to use the keyword `variable' when you need the value to change.
Show differencesHistory of post edits
#1alvaro
Posted 01 February 2012 - 09:06 PM
Whether a parameter in a prototype is const or not makes no difference whatsoever. Not to the compiler, not to someone trying to use your function or reading your code. So having it there only makes things less clear, since it's not customary to have it there and it might lead someone to believe it means something.
The way I program, most of my local variables are initialized when they are defined and their values never change, so I could make them all `const', and the compiler would tell me if I am accidentally changing one. But this is very rarely a mistake I make, and the overabundance of `const's would clutter the code and make it harder to read, so I don't do it.
If I were designing the language, perhaps I would make the default be `const' and you would have to use the keyword `variable' when you need the value to change.
The way I program, most of my local variables are initialized when they are defined and their values never change, so I could make them all `const', and the compiler would tell me if I am accidentally changing one. But this is very rarely a mistake I make, and the overabundance of `const's would clutter the code and make it harder to read, so I don't do it.
If I were designing the language, perhaps I would make the default be `const' and you would have to use the keyword `variable' when you need the value to change.