Is there any program for adding Clojure brackets?

When I learn some Clojure languages, readability and syntax usability is the most important issue (probably wrong).
Thus, Clojure is very appealing to me, but there can be a lot of parentheses to support.
And I am considering if there is a script with which I can write the code without any brackets and then compile it in Clojure, that should be better. Does such a program still exist?
(Once said there is indentation syntax for Scheme , which is nice. How about Clojure?)


source to share

2 answers

You usually use an editor or IDE to take care of your braces.

It is especially useful to have "rainbow parens", that is, the parentheses are different colors to match their nesting level so you can quickly see how they line up.

Some parameters:

  • The Counterclockwise plugin for Eclipse is great if you are already an Eclipse user and want to mix Clojure and Java code.
  • Emacs is a common choice for Lisp programmers. There is a pretty good set of Clojure tools for Emacs

Note that in general, due to its brevity, Clojure code uses fewer parentheses than the equivalent Java code .



Once you get used to parens, they become easier to read than Java code. More important for readability is proper indentation. Any decent IDE will fix the code block indentation for you.

However, you may find that macros do what you want. For example, a macro macro (->) or a macro. And you can write your own macros for more specific purposes.

Here's an example:

user => (str (inc (Integer / parseInt "10"))) "11"

can be rewritten as user => (-> "10" Integer / parseInt inc str) "11"

Saving two paired pairs! Woot!

Going back to the original question, if you can write non-ambiguous code with fewer parsers for a given situation, then it should be possible to write a macro to expand the less-parens syntax in real Clojure. Do you have an example of what you are looking for?



All Articles