There is another benefit to using const over value: if you define a
parameter as value, the compiler will allow code to change its value. With
const, you cannot change the value of the parameter variable once it has
come in to the procedure.
What's the big deal, you ask? First, using const will preserve the original
parameter values, which can be very handy at times. Second, if you use
*nopass a lot, you can cause troubles by using the passed in parameter if it
was not in fact passed in to the procedure. By using const, the compiler
will help protect you against this to an extent by preventing you from
changing the variable. Yes, the non-passed variable can still be (mis)used,
but at least you get a little help using const.
What I do instead is define all the parms as const, and then have supporting
variables in the procedure with default values. I then set the supporting
field values accordingly if the parameter was sent. Then in the rest of the
procedure, I only use the supporting parameters. This is also a good
approach for *omit parms. There is an example of this in this article:
http://www.itjungle.com/fhg/fhg010505-story02.html
I hope this is somehow helpful.
As an Amazon Associate we earn from qualifying purchases.