* David Brown: > Far and away the best solution would be for C++ to support named > parameters or named arguments: > > <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4172.htm> > > Then you could write: > > foo(1, 2, bar_p: true); > > You could also write > > foo(y: 2, bar_p: true, x: 1) > > and get the same call. > > It is always much better if you can put something in code rather than a > comment.
True, but I don't think this is possible because function argument names are explicitly *not* part of the API today (and are often mangled in public header files, if they are included at all). Something analogous to std::initializer_list, but for C99 designated initializer syntax might be more acceptible. So in your example: foo({.y = 2, .bar_p = true, .x = 1}) The advantage is that functions supporting this invocation style would have to be marked explicitly in the sources, so there would not be an accidental source code dependency on a non-portable aspect of system header files.