Skip to content

Should indented comments allow hanging closing parentheses? #259

@shaunlebron

Description

@shaunlebron

The style guide says to “gather trailing parentheses”. Does this imply that the following is incorrect?

(“rich-comment” example from yuhan0’s comment in Standard Clojure Style discussion)

;; Incorrect?
(comment
  (range 5)
  ;; => (0 1 2 3 4)
  (interpose '* (range 5))
  ;; => (0 * 1 * 2 * 3 * 4)
  )

And the following is correct?

;; Correct?
(comment
  (range 5)
  ;; => (0 1 2 3 4)
  (interpose '* (range 5)))
  ;; => (0 * 1 * 2 * 3 * 4)

An auto-formatter might make the above correction to follow the “gather” rule, but then might dedent the comment since it’s no longer inside:

;; More correct?
(comment
  (range 5)
  ;; => (0 1 2 3 4)
  (interpose '* (range 5)))
;; => (0 * 1 * 2 * 3 * 4)

Perhaps to avoid this cascade of corrections, should it be recommended to use a placeholder on the hanging closing paren?

;; Better?
(comment
  (range 5)
  ;; => (0 1 2 3 4)
  (interpose '* (range 5))
  ;; => (0 * 1 * 2 * 3 * 4)
  ,)

Calva uses an :rcf placeholder instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions