You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid using those in situations that would result in hanging closing parentheses.
But the given example seems to break the second rule:
(defnfoo [x]
x; I'm a line/code fragment comment.
)
Proposal
The example below from @yuhan0 follows these rules— by not expecting an inline comment to directly follow its referent expression (AST-wise):
(defnclassify-squares [n]
(->> (range n) ; generate a bunch of numbers
(map #(* % %)) ; calculate their squares
(group-by even?))) ; and sort them by parity
This seems more conventional than the other example, which I actually haven’t seen before.
Rationale
One way to formalize this is to treat margin comments as actual sidenotes:
Treat anything after an inline semicolon ; as “in the margin”.
I think the rules for margin comments are causing some confusion in the related Standard Clojure Style discussion:
Problem
The Clojure Style Guide’s rules for margin comments states:
But the given example seems to break the second rule:
Proposal
The example below from @yuhan0 follows these rules— by not expecting an inline comment to directly follow its referent expression (AST-wise):
This seems more conventional than the other example, which I actually haven’t seen before.
Rationale
One way to formalize this is to treat margin comments as actual sidenotes:
;
as “in the margin”.The text was updated successfully, but these errors were encountered: