← Back to context

Comment by WalterBright

2 years ago

The compiler can verify for you that a pointer to const does not modify the pointed to data. It is not necessary to document it.

There are a number of constructs in C that require documentation because they are not expressible in code. More expressivity in the language reduces the documentation required. An ownership/borrowing capability means one doesn't have to document who the "owner" is. And so on.

As said in the other conversation, you're missing what's being communicated. And as __explicitly__ stated in the comment you replied to (this comment's gp), the compiler tells you __nothing__ about the logic. It can't! The compiler doesn't know human intention. It can tell you that you've accessed an out of bounds index, but it can't tell you that you selected the wrong index. These are very different things!

A compiler only tells you about semantic errors. It has no understanding though. This is true for any language. We can say/write things that are linguistically correct but have no actual meaning and tells us nothing about the "correctness" or efficiency of our usage.

Comments are for the logic, not grammar. The logic is abstract.