Vadim Dalecky1 year ago

Code comments normally don’t just float there in isolation. They are mentally attached to some piece of code.

Single-Line comments

A comment which consumes the whole line refers to the code elements which starts on the next line:

A comment to the right of some code refers to the expression just before the comment.

When a line has multiple expressions, the right-side comment refers to the last expression.

What is the meaning of a single-line comment after all the code?

There also could be a general global comment before any code:

Global comments shall be separated from the code by at least one blank line.

Multi-line comments

Multi-line comments are more complex than single-line comments, as multi-line comments can appear in all the same place where single-line comments appear, but in addition: (1) multi-line comments can appear in more places; (2) multi-line comments can span multiple lines.

Since a “multi-line” comment can be in the middle of the source code, it can be attached from the left or from the right of some expression: