4 ms·
One problem with Lisp is everything, including variable bindings, increases the nesting level making the code illegible. Last thing you want is for the type dec
by HexDecOctBin 1y ago
One problem with Lisp is everything, including variable bindings, increases the nesting level making the code illegible. Last thing you want is for the type declaration to have their own nesting.
- zarathustreal 1y agoThis is not necessarily true, you can pretty easily implement just about any syntax you want
- dokyun 1y agoIf you hate nesting, just do this (defun foo (&aux bar baz) (setq bar (quux) baz (xyzzy)) ...)
- epgui 1y agoThe nesting level doesn’t necessarily impair legibility, it depends how it’s done. Nesting levels in homoiconic & referentially transparent languages have an impact more comparable to nesting levels in yaml or json than nesting levels in a language like python or javascript. The tradeoff weighs in a completely different way. First you will usually want to write small chunks of code, instead of a large soup. Second, you can make intentional decisions with your use of newlines in order to highlight specific aspects of the code. I find clojure more readable than most other languages… However, bad code stands out horribly (which is actually great if you have at least one experienced engineer in the team- I’d argue there’s nothing worse than bad code that looks normal). Just like anything else, writing good lisp takes some skill. Your specific editor and its configuration will also have a big impact on your experience.
- sdsd 1y agoYou'd love threading macros in Racket: https://docs.racket-lang.org/threading/index.html https://docs.racket-lang.org/threading/index.html It's like Unix pipes for functions: (~> "hello" (string-ref 1) (char->integer))
- klibertp 1y agoObviously, also available in CL, in Serapeum library[1]. Racket is credited in the docstring (since it's ~> instead of ->). Also, `nest` works very well for unnesting forms[2] [1] https://github.com/ruricolist/serapeum/blob/master/control-flow.lisp#L688 https://github.com/ruricolist/serapeum/blob/master/control-f... [2] https://github.com/ruricolist/serapeum/blob/master/REFERENCE.md#nest-rest-things https://github.com/ruricolist/serapeum/blob/master/REFERENCE...
- sham1 1y agoAside from the points that others have raised already, this sort of deep nesting can be seen as a feature instead of as a bug, since it can force you to think about refactoring the code into being less nested.