Topic: Keyword parameters
Author: dag@control.lth.se (Dag Bruck)
Date: Mon, 10 May 1993 16:11:22 GMT Raw View
In <comp.std.c++> jpsa@arc.ug.eds.com writes:
>
>The big advantage comes when calling a function which takes a lot of
>parameters which have default values. If you only want to override
>one or two of them, then (at present) you have to re-specify the default
>values for any which precede the ones which must be changed. With keyword
>parameters, you need only specify the ones of interest.
Just a few comments on how to cope without keyword arguments.
1. Objects have state. Functions in typical C++ programs seems to
have rather short argument lists. The reason is that much state
information is kept in object, I think. In FORTRAN for example, you
often have to carry state information to various subroutines via
additional vectors.
2. Overloading. You can overload the general function that takes
many arguments to handle the common cases more easily. If you make
the short forms inline, there is no overhead.
-- Dag