4 ms·
Your analysis only holds if closing parentheses are all gathered on the same line as final expressions (which may not be true for some styles).
by yohanatan 12y ago
Your analysis only holds if closing parentheses are all gathered on the same line as final expressions (which may not be true for some styles).
- loumf 12y agoI'm not thinking this through completely, but it seems resilient to a lot of styles. Function calls (which is a lot of what clojure is) are an open parens to start and very likely not to have that close on the same line (because you are building a tree of subexpressions). Wherever you put the close (bunched or one per line), if you don't put it on the line with the original open, it will be unbalanced in both spots (meaning the first line and the last line can't be duplicated without causing a syntax error).
- yohanatan 12y agoTrue. But consider the form: (if (someExpr) (doTrueStuff) ) Then a duplication of the `doTrueStuff` line would lead to true stuff being done regardless of the truthiness of someExpr (as the third [optional] argument to `if` is the else branch). This form is not entirely unheard of either. The overtone library for example assigns labels to its event handlers like such: (defn eventHandler ( ... stuff ) :: event_handler_label)
- Jtsummers 12y agoThis is actually why I really like `cond` in Common Lisp (and other lisps and languages). You have to make explicit what should happen if your desired expression is true, and the only way to have an `else` clause is `(t ...)` so you have to intentionally create that last wildcard spot.
- chc 12y agoIt is considered unidiomatic in every Lisp I am aware of to orphan parens. To some degree this is a stylistic concern, but it's a much more open-and-shut case than, say, C brace style.