Search code examples
clojurecompiler-constructionparentheses

clojure terminating parenthesis syntax


Is there any reason why the expression

(foo5 (foo4 (foo3 (foo2 (foo1 arg)))))

cannot be replaced with

(foo5 (foo4 (foo3 (foo2 (foo1 arg)-)

or the like, and then expanded back?

I know lack of reader macros means that you cannot change syntax, but can this expansion possibly be hard coded into the java?

I do this when I hand write code.


Solution

  • Yes, you could do this, even without reader macros (in fact, you can change Clojures syntax with a bit of hacking).

    But, the question is, what would it gain you? Would it always expand to top-level? But then cutting and pasting code would fail, if you moved it to or from top level. And, of course, all the various tools that operate of clojure syntax would need to understand it.

    Ultimately if you really dislike all the close parens why not use

    (-> arg foo1 foo2 foo3 foo4) 
    

    instead?