3 ms·
Thanks for the example! To be completely clear, this is what I meant: Suppose this is the function we want to document (using examples modified documentation
by tareqak 9y ago
Thanks for the example!
To be completely clear, this is what I meant:
Suppose this is the function we want to document (using examples modified documentation tests:
fn foo {
let x = 5;
let y = 6;
println!("{}", x + y);
}
Suppose we have a documentation requirement/heuristic of requiring the comment to have all the variables that are declared in the body of any given function. Then a comment like this would pass because whatever compilation step /processor sees that `x` and `y` both appear in the comment.
// Prints x + y
This would fail because `x` is not found:
// Prints z + y
This would pass but is not useful/misleading/wrong.
// y - x FTW!!!
This example is trivial and only uses the one simple heuristic such that it is both onerous and useless, but it would force the writer of the code to also write comments in accordance with said heuristic. In this particular case, if someone modifies the variable name, adds a new variable, or removes and existing once, then the compiler would force that individual to make a necessary change to that particular comment such that the comment cannot become stale (but the heuristic is bad, so it could still be useless :) ).
- hamandcheese 9y agoI would argue that externally documenting declarations inside the function is not particularly helpful.