This is mostly solved in languages with named parameter calling (if you use it). Example: createFile(name, contents, temporary=True)
Sometimes it is already obvious enough. In C I have no problem with set_visible(item, true);
This is mostly solved in languages with named parameter calling (if you use it). Example: createFile(name, contents, temporary=True)
Sometimes it is already obvious enough. In C I have no problem with set_visible(item, true);
I’ve found the odds of that happening approach certainty once you have more than one or two parameters. If you’re using a language without named arguments I usually treat adding a third parameter as a cue to reconsider using a more idiomatic interface, whether that’s something like classic Java OOP (.setTemporary(true)) or limiting that knowledge to one place by e.g. creating a subclass, struct, or a specialized function so you call createTemporaryFile() and know that ordering check only needs to be done in one place rather than by every caller.
For example, you could mean
createFile(name, contents, /* temporary= */ true, /* overwrite= */ true)
but write createFile(name, contents, /* overwrite= */ true, /* temporary= */ true)
by accident.Writing documentation that that merely copies existing code is terrible: it's either going to be wrong (because it's not automatically checked and will go sour in a refactoring, or it's right because it's so obvious that no one will guess wrong when looking at it.)
int temporary = true;
create_file(path, contents, temporary); create_file(path, contents, temporary:=true);Unless you are using a different definition of named parameters, I've never seen C++ code in the wild that used them.
http://www.cs.technion.ac.il/users/yechiel/c++-faq/named-par...