5 ms·
That isn't how that defun would normally be formatted, though. Lisp knows that the 'body' part starts with the 3rd argument (the same way Clojure knows it start
by kbp 7y ago
That isn't how that defun would normally be formatted, though. Lisp knows that the 'body' part starts with the 3rd argument (the same way Clojure knows it starts with the second), so it indents the lambda list farther right (if it doesn't fit on the first line, otherwise it would go there).
For my eyes, [] aren't distinct enough from () to make the second style preferable. I'd rather have indentation to set it apart.
- nickbauman 7y agoI just made them consistent. It certainly helps me visually. Also a list implies you intend to evaluate it by executing a function. A vector implies you do not intend to call a function.
- kbp 7y agoYeah, it's definitely a taste thing, but as the first style isn't used in Lisp, comparing its readability doesn't really make sense. Indentation is important to reading Lisp. Indenting it in an odd way makes it harder to parse. It's a bit like giving def foo(x) bar(x) end as an example of Ruby syntax being overly homogeneous.
- lispm 7y ago(defun averagenum (n1 n2 n3 n4) (/ (+ n1 n2 n3 n4) 4)) The typical pattern is DEFSOMETHING name arglist body A Lisp programmer reads those structural patterns, not the delimiters. Lisp programming is more about thinking of trees of code and their possible manipulation - even independent of a visual notation and especially independent of the exact delimiter used. The delimiters are in shape recognition much less important than the shape itself.
- nickbauman 7y ago"A Lisp programmer" ... Sheesh, I am a lisp programmer, man, and I assure you I know what trees of code independent of visual notation is. You're making a point that doesn't need to be made here. It's this kind of phrasing that really turns off people from the lisp community. I wrote it that way so it's easier for non-lisp programmers to compare with what they're more used to as well.
- lispm 7y agoThat doesn't help them. Explain it like it is. Lisp is different from what they are used to.