4 ms·
The point is not to reduce the comment to the assert, but to detect when the comment is outdated. If a comment is referring to another function in the code, the
by Grue3 8y ago
The point is not to reduce the comment to the assert, but to detect when the comment is outdated. If a comment is referring to another function in the code, then assert would check that the function exists. If you refactor the code and remove the function, you'll have to refactor this comment as well.
A docstring describing arguments to a function would check that the list of arguments to a function is exactly as described in the comment. If you add a new argument, you have to edit the docstring.
And so on.
- anoncake 8y agoThat actually sounds interesting, but I dont see why youd need an assert for that. If you markup the comment appropriately so the compiler or a linter sees when you mention another function and identify where you describe the arguments in a docstring, it could do these checks statically. In fact, Im pretty sure Javadoc and other tools already have that markup.