Hacker News new | ask | show | jobs
by MarceColl 429 days ago
I think it really depends, in Common Lisp for example I don't think that's the case:

  (progn
    (do-something)
    (do-something-else)
    (do-a-third-thing))
The only case where it's a bit different and took some time for me to adjust was that adding bindings adds an indent level.

  (let ((a 12)
        (b 14))
    (do-something a)
    (do-something-else b)
    (setf b (do-third-thing a b)))
It's still mostly top-bottom, left to right. Clojure is quite a bit different, but it's not a property of lisps itself I'd say. I have a hard time coming up with examples usually so I'm open to examples of being wrong here.
1 comments

Your example isn't a very functional code style though so I don't know that I'd consider it to be idiomatic. Generally code written in a functional style ends up indented many layers deep. Below is a quick (and quite tame) example from one of the introductory guides for Racket. My code often ends up much deeper. Consider what it would look like if one of the cond branches contained a nested cond.

  (define (start request)
    (define a-blog
      (cond [(can-parse-post? (request-bindings request))
             (cons (parse-post (request-bindings request))
                   BLOG)]
            [else
             BLOG]))
    (render-blog-page a-blog request))
https://docs.racket-lang.org/continue/index.html
Common Lisp, which is what I use, is not really a functional oriented language. I'd say the above is okay in CL.
I must have missed that memo. Sure it's remarkably flexible and simultaneously accommodates other approaches, but most of the code I see in the wild leans fairly heavily into a functional style. I posted a CL link in an adjacent comment.

Here's an example that mixes in a decent amount of procedural code that I'd consider idiomatic. https://github.com/ghollisjr/cl-ana/blob/master/hdf-table/hd...