Hacker News new | ask | show | jobs
by mattstir 977 days ago
This may just be my inexperience with the intricacies of C++, but it seems like a decent number of the problems raised here could be fixed by allowing one to name default args like proper keyword arguments. Consider the first issue discussed and how naming the argument just fixes it:

  print_square('*');
  print_square(fill='*'); // Hypothetical fix
It also seems to be an issue exacerbated by C++ implicitly converting a char into an int.

> The client programmer doesn’t want a “puzzling” print_square(x) that treats x sometimes as a side length and sometimes as a fill character!

This is also fixed if C++ allowed you to name keyword arguments explicitly (and didn't sometimes implicitly convert types, but that's baked in pretty hard by now).

> The “boolean parameter tarpit”

Again, imagine how much more understandable it would be if you could write:

  doTask(task1, 100s, catchStderr=true);
I wonder whether the author would change their stance on default args if they were made to be more usable.