3 ms·
FunCall1( FunCall2( FunCall3(arg1, arg2, arg3))) vs (FunCall1 (FunCall2 (FunCall3 arg1 arg2 arg3))) Yes those useless parentheses certainly clutter up the
by greggyb 10y ago
FunCall1( FunCall2( FunCall3(arg1, arg2, arg3)))
vs
(FunCall1 (FunCall2 (FunCall3 arg1 arg2 arg3)))
Yes those useless parentheses certainly clutter up the code. Look at how much longer the lispy line is compared to the less lispy line. Why it's got a whole -3 more characters!
And the end of the line with all the parentheses. So much uglier to see three parens at the end of the lisp line than the non-lispy line.
Truly a monstrous imposition, that lisp syntax.
And when you look at any lisp code base, look at how they don't indent their code at all. So unlike other languages.
Here's literally the first project I could find looking for "lisp source code": https://github.com/adamtornhill/LispForTheWeb/blob/master/web_with_persistent_backend.lisp https://github.com/adamtornhill/LispForTheWeb/blob/master/we...
- Rovanion 10y agoWhich can be rewritten as: (-> (FunCall3 arg1 arg2 arg3) Funcall2 Funcall1) in Clojure. https://clojuredocs.org/clojure.core/-%3E https://clojuredocs.org/clojure.core/-%3E
- greggyb 10y agoSo, you're telling me that users of a language known for syntactic abstraction came up with a way to more conveniently express a common pattern of code? Well color me flabbergasted.
- alkonaut 10y agoTo be fair, both the imperative and the lisp version of that are probably not optimal. In most imperative (OO) languages the first one could hopefully be Fun3().Fun2().Fun1() or even thing3.thing2.thing1 If some thing is a property of the other Concrete example from your linke: a projection and sort (I believe it is). I think that the tail of this expression with 5 parentheses makes this very hard to read (Admittedly it's a matter of experience of course): (docs (iter (db.sort *game-collection* :all :field "votes" :asc nil))))) Questions I find hard to answer for the above line is: how many args does "iter" have? Is 5 trailing parentheses the right number? Here is some half-functional half-imperative strawman syntax: for comparison: x = some_collection .select(c -> c.documents) .sort(d -> d["votes"], direction: ascending); I find that a lot easier to balance, and know how many arguments the projection has compared to the sort.
- kazinator 10y ago> Questions I find hard to answer for the above line is: how many args does "iter" have? It's obvious to me in a millisecond glance that docs and iter are called with one argument. For one thing, the snippet does not contain a single instance of a ) parenthesis being followed by a ( parenthesis. Also, none of the ) parentheses have any material between them. It's just (sym (sym (sym stuff ...))). Only three trailing parens are required to close (docs; the other two are for something else. If iter had additional arguments, it might be written like this: (docs (iter (db.sort *game-collection* :all :field "votes" :asc nil) (another-iter-arg))) It is still obvious that docs has one arg, iter has two and that the :all :field material is under db.sort. https://news.ycombinator.com/item?id=9229339 https://news.ycombinator.com/item?id=9229339
- alkonaut 10y agoAh, the arg-count-from-indentation makes sense with the concrete example, thanks. That said: if the code is neither correctly indented or has the parens correctly balanced - then one is in a pickle. It's easy to balance parens on correctly indented code, and it's trivial to indent correctly balanced code.