Const redemption day !

I have to confess something : I have a problem with constants.

As a vile former C user, I have a spontaneous tendency to replace numeric constants with #defines. But that’s not really an issue, except in very specific cases that never happen (TM). No, my issue is that I never, ever declare my function parameters as const. I’m still a bit used to the pascal way of things where function parameters are constant unless declared otherwise. And because of that, each time I have to overload some operator which takes a constant parameter, it is a much more time-consuming and tedious process than it should be (not to mention some obvious bugs that are not detected by the compiler).

But everything can change someday. So I declare that today is the “const redemption day” : I’m parsing my code, and putting const in every place where they should have been there in the first place. And I encourage all people who find C’s way of making every single function parameter variable stupid but don’t bother to use the “const” word to do the same. After all, the fact that the language encourages poorly written code is not an excuse for writing such code ;)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s