May 10, 2005
>Unless I missed something in the doc, it looks like D handles default template arguments just like C++.  I.e. you can't specify the Nth without specifying all the ones before it too.

Right.

>So c'mon people, I can't be the only one who finds having to manually specify lots of default parameters to be irksome and a completely unnecessary practice in the 21st century.  Can I?

In the 21st century you just don't have things with many paramters. So you can't have things with many default paramters.

e.g. group some of the parameters to structs and pass them.

A function like

# void foo (Bar bar, Baz baz, Qux qux, XXX xxx, YYY yyy, ZZZ zzz);

gets

# void foo (Bla bla, Blub blub);

and is called like:

# foo (Bla (bar, baz, qux), Blub (xxx, yyy, zzz));

This way you can do things like this:

# Bla defaultBla  = ...;
# Blub defaultBlub = ...;
#
# ...
#
# foo (defaultBla, Blub (xxx, yyy, zzz));


But perhaps you should rething your design in general if you have functions with many arguments.

-- Matthias Becker


1 2
Next ›   Last »