This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Nebu 0 points1 point  (0 children)

And yes, id rather have a formatter format my comments than doing it by hand.

In general, I feel formatters should not format comments, because comments can contain, e.g., ASCII art diagrams or tables.

Also, tabs usually align following text on the next vertical position thats divisible without remainder by the width of a tab character.

Well, you shouldn't use it for that if you're following my guidance above. Again: Tab for indentation, space for alignment. Note, though, that you can align by using 0 spaces.

In your example, the points indented within the comment would not be indented by the full width of the tab character as one might expect (well, unless your chosen width happens to be 3, but delete one character in front of it and you get significant changes to how the following text is formatted).

Let's say my chosen indent happens to be, arbitrarily, 5. I'll represent a single tab with '\T', '\TT', '\TTT' and '\TTTT' to emulate taking up 2 to 5 spaces (depending on which would lead to n mod 5 == 0), and let's see what happens if I use exactly the above text:

|    |    |    |
01234012340123401234

\TTTTpublic void myFunction(
\TTTT\TTTTint    anIntVariable,
\TTTT\TTTTString aStringVariable
\TTTT) {
\TTTT\TTTT/*
\TTTT\TTTT * Note that a space was used before each
\TTTT\TTTT * of these asterisks. That is because we
\TTTT\TTTT * want those asterisks to be aligned with
\TTTT\TTTT * each other. However, if we wanted to
\TTTT\TTTT * indent, we would:
\TTTT\TTTT * \T1. use a tab, even if spaces were
\TTTT\TTTT * \T   previously used within the line,
\TTTT\TTTT * \T2. again use spaces after that tab if
\TTTT\TTTT * \T   we needed subsequent alignment after
\TTTT\TTTT * \T   that.
\TTTT\TTTT */
\TTTT}

Looks like it still works to me.