I want to make this thread so I can ask for pointed feedback on the style of the formatter and any general questions about expectations around formatting
I have this EXTREMELY OVER COMMENTED block of code. Does this look how people could expect it to look if someone had typed this in? I.e., should this parse and format stably? (Please ignore \\ for zig multiline comments)
const stmt =
\\import # Comment here
\\ pkg # And here
\\ .Something # Another one
\\ exposing # Still commenting
\\ [ # I really like comments
\\ func # Commenting for life
\\ as # Even here
\\ function, # And here
\\ Type # Commenting again
\\ as # And again...
\\ ValueCategory, # Why can't I stop?
\\ Custom # This is getting ridiculous
\\ .* # Even Uncle Bob is emabarrased
\\ ] # And...I'm done
;
Seems not unreasonable
I guess the big question is: is the principle that in a continuation where there is a comment not at end of line (and not in some collection) that we indent on the next newline and continue?
Or should things like qualifier and identifier proceed at the same level of indent?
The alternative would be:
const stmt =
\\import # Comment here
\\ pkg # And here
\\ .Something # Another one
\\ exposing # Still commenting
\\ [ # I really like comments
\\ func # Commenting for life
\\ as # Even here
\\ function, # And here
\\ Type # Commenting again
\\ as # And again...
\\ ValueCategory, # Why can't I stop?
\\ Custom # This is getting ridiculous
\\ .* # Even Uncle Bob is emabarrased
\\ ] # And...I'm done
;
I'll also write up an example with complex binops as well. There are SO many places where comments could be inserted there
On balance, less rightward drift seems good - but this is such an unusual situation that I’m not particularly concerned about it
I'd push for less rightward drift whenever consistently possible, so the second example is preferable to me
Hmm. I think it should be consistent with what we would do for a function chain
x
.y
.transform()
.run!()
So I would vote for this:
const stmt =
\\import # Comment here
\\ pkg # And here
\\ .ExtraNesting # not sure this is actualy valid, but just an example of more nesting
\\ .Something # Another one
\\ exposing # Still commenting
\\ [ # I really like comments
\\ func # Commenting for life
\\ as # Even here
\\ function, # And here
\\ Type # Commenting again
\\ as # And again...
\\ ValueCategory, # Why can't I stop?
\\ Custom # This is getting ridiculous
\\ .* # Even Uncle Bob is emabarrased
\\ ] # And...I'm done
;
yeah I agree with that
I don't think anyone is actually going to write comments in all these places, so I don't think the quantity of indentation really matters here
I think what's more important is that if you put comments in a small subset of these places, it looks consistent with what we do elsewhere
Last updated: Jul 06 2025 at 12:14 UTC