Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indent even [ and cond subexpressions? #248

Closed
vspinu opened this issue Aug 4, 2014 · 2 comments
Closed

Indent even [ and cond subexpressions? #248

vspinu opened this issue Aug 4, 2014 · 2 comments

Comments

@vspinu
Copy link
Contributor

vspinu commented Aug 4, 2014

Hi,

With the parentheseslessness of clojure comes the burden that the indentation of the multi-line code becomes awkward.

Would it be posible to shift even clauses of cond by 2 spaces? An example from clojure.core:

(let [ev (eval v)]
    (cond 
     (instance? java.lang.Enum ev)
     (.visitEnum av name (descriptor (class ev)) (str ev))
     (class? ev)
     (.visit av name (clojure.asm.Type/getType ev))
     :else (throw (IllegalArgumentException. 
                    (str "Unsupported annotation value: " v " of class " (class ev))))))

Could it be:

(let [ev (eval v)]
    (cond 
     (instance? java.lang.Enum ev)
       (.visitEnum av name (descriptor (class ev)) (str ev))
     (class? ev)
       (.visit av name (clojure.asm.Type/getType ev))
     :else (throw (IllegalArgumentException. 
                    (str "Unsupported annotation value: " v " of class " (class ev))))))
@bbatsov
Copy link
Member

bbatsov commented Dec 6, 2014

Never seen such style in practice, so I'm very wary about supporting it. I feel your pain, though. The effort to drop some parentheses in Clojure was a big misguided IMO.

@vspinu
Copy link
Contributor Author

vspinu commented Dec 7, 2014

I have developed a habit of leaving one line between the conditionals. The proposed indentation has an unpleasant drawback. Long conditions look like function calls; especially problematic with multiline statements:

(let [ev (eval v)]
  (cond 
   (instance? java.lang.Enum ev)
     (.visitEnum
       av name (descriptor (class ev)) (str ev))
   (class? ev)
     (.visit
       av name (clojure.asm.Type/getType ev))
   :else (throw (IllegalArgumentException. 
                 (str "Unsupported annotation value: " v " of class " (class ev)))))

@vspinu vspinu closed this as completed Dec 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants