Skip to content

Instantly share code, notes, and snippets.

@onealexharms
Created July 19, 2014 18:48
Show Gist options
  • Select an option

  • Save onealexharms/8570e4237705608e209d to your computer and use it in GitHub Desktop.

Select an option

Save onealexharms/8570e4237705608e209d to your computer and use it in GitHub Desktop.
which is more readable?
(cond
(includes-failure-message?
(set! message (car args))
(set! condition (cadr args)))
(else
(set! condition (car args))))
(cond
(includes-failure-message?
(set! message (car args))
(set! condition (cadr args))
)
(else
(set! condition (car args))
)
)
@rdm
Copy link
Copy Markdown

rdm commented Jul 19, 2014

Taken by itself, I'd give a different answer than if this was a part of a larger body of code.

It's an overall effect that I am usually looking for.

@unclebob
Copy link
Copy Markdown

The first is more traditional and easier to read for a long-time lisper. IMHO.

@michaelfeathers
Copy link
Copy Markdown

To me, the first one is more readable, and I think there's a reason why it should be preferred. If you make your code so complex that the whitespace in the second one is valuable then it needs simplification. To me, that means that the first example provides a back-pressure on complexity that's useful.

I lean toward concision as long as people pay attention to semantics enough to keep code understandable.

@michaelfeathers
Copy link
Copy Markdown

In well-written Lisp, you don't have to think about or look at the parens.

The problem with the second example is that it implies that you do.

@jbrains
Copy link
Copy Markdown

jbrains commented Jul 20, 2014

I'll take the first one, but with consistently-used 2-space indentation. :) I find the almost-blank lines in the second version distracting. I find it easier to clean the structure of the first one.

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