⚡ Sangsakala Proxy 🏠 Home
Skip to content

Clarify if indentation #229

Open
Open

Description

@gpind

By my reading of https://github.com/bbatsov/clojure-style-guide#vertically-align-fn-args, we should indent if like so:

(if condition
    (f1)
    (f2))

...but that's contradicted by other examples in the guide, which use the common two-space indentation for if. Technically the rule might not cover if since it's a special form and not a macro, but there's also if-let and if-some and it would be very weird IMO to indent them differently. It would be good to mention this explicitly, even if just to call out if and friends as exceptions.

(I searched for existing issues covering this, but the closest I found was #87.)

Activity

  1. bbatsov commented on Oct 30, 2021

    @bbatsov
    Owner

    All macros/special forms that take a body parameter are indented differently, so I don't think there's anything special about the handling of if, if-let and so on. Can you elaborate on what exactly is different for them from your perspective compared to other macros operating on a bunch of forms?

  2. gpind commented on Nov 1, 2021

    @gpind
    Author

    if doesn't have a body param, so it shouldn't be covered by the "Body Indentation" rule, right?

  3. bbatsov commented on Nov 4, 2021

    @bbatsov
    Owner

    Yeah, I guess that's a valid point. Perhaps the bare if deserves some special treatment, or at least a disclaimer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions