Constant Arguments

I just started thinking, why do pretty much all languages define arguments as regular variables instead of constants? The way I see it, the most common feature should be the default behavior, and how often do you need to (or more importantly, “should you”!) change the value of an argument variable? I can’t think of a single time that I’ve done so with a good reason. With some languages (like the simple Scheme interpreter, %scheme, we’ve implemented reading our SICP-based course) it’s simply easier to omit the use of constants altogether. We did it because it was simpler. But every other language, why would anyone chose to do this? I have no answer. I know that every time I touch Java I’m tempted to insert a billion final keywords in front of all arguments just to potentially catch an error. It would be so much easier if arguments were constant by default, and then when necessary, one could insert a keyword to make them variable. Or perhaps they could just be constant and that’s it, don’t mess with my arguments!

Has everyone simply fallen into the trap of doing like everybody else just because it’s always been done this way? Or is there some good reason hidden behind all of this? Please, do tell if you know.

My imaginary language (that I’ll probably never get around to creating) will have constant arguments.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options