Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Margin (inline) comments allow hanging closing parentheses? #258

Open
@shaunlebron

Description

@shaunlebron

I think the rules for margin comments are causing some confusion inthe related Standard Clojure Style discussion:

Problem

The Clojure Style Guide’srules for margin comments states:

  1. Write margin comments with one semicolon.
  2. 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 actualsidenotes:

  1. Treat anything after an inline semicolon; as “in the margin”.
  2. Gather trailing parentheses by ignoring anything in the margin.

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp