On 2010-02-18 16:11:39 -0500, Jonathan M Davis <[email protected]> said:
Michel Fortin wrote:
Would't that be nice to be able to use the 'default' keyword when you
want to use the default value for a parameter? Should be pretty trivial
to implement.
Except that to some extent, that would defeat the purpose of default
parameters. Part of the idea is that you don't have to worry about their
existence unless you actually want to change them. If you're going to have
to put the word default there, then in many cases, you might as well just
put an actual value yourself.
The one thing that word default would give you would be the ability to
choose the the default value for parameters in the middle of the parameter
list and still give values for parameters at the end. But that's just extra
complication and likely wouldn't be worth the benefit.
I don't see the complication you talk about. It's no complication
unless you use it, and if you feel the need to use it it's probably
because there's a benefit. You can still call functions with default
parameters by omitting the parameters if you want, I'm not trying to
change that.
void test(int a = 1, int b = 2);
test(); // same as test(1, 2);
test(8); // same as test(8, 2);
test(default, 8); // same as test(1, 8); <- here it's useful
--
Michel Fortin
[email protected]
http://michelf.com/