Where are the the comments in dmd?

Walter Bright newshound2 at digitalmars.com
Mon May 3 20:09:21 UTC 2021


On 5/3/2021 6:25 AM, Imperatorn wrote:
> Btw, just as a comparison (not trying to make a point) I looked at Crystal 
> (because it was discussed earlier) and it actually has even less comments, not 
> even trying in many places.

Interestingly, when I write initial code I know what I'm doing and think it is 
obvious, and rarely bother with comments.

The comments come in the second time I work on it, as I don't recall how it 
works and have to figure it out. I'll comment the non-obvious stuff I have to 
work out again.

The third, fourth, etc., times this happens is when the comments get even better.

It's an iterative process.

Also, quite a bit of the documentation in the code is not in the comments at 
all, it is in the coding style. For example, variable name `e` is for an 
Expression, `t` for Type, `td` for TemplateDeclaration, etc. This helps a lot.

There's a lot of compiler jargon used, too. Getting a copy of the "Dragon Book" 
will help with this.

https://www.amazon.com/Compilers-Principles-Techniques-Alfred-Aho/dp/0201100886


More information about the Digitalmars-d mailing list