Clojure subset in indentation-based syntax

JiyinYiyong
Cirru Project
Published in
2 min readNov 4, 2015

Clojure is a great language combine the magic of Lisp and the power of JVM. As I began to learn Clojure, I found myself really want a indentation syntax for Clojure. Now I got one:

Cirru Sepal is my project started to compile Cirru AST into ASTs of various languages, this is the Clojure one. Macros are so powerful and it only took me a few tens of line to finish this transformer. And it works.

Also I created a little Leiningen plugin to help me with the compiling process, here it is:

Just create `cirru-src/` and `cirru-test/` in the project root, and start with `lein cirru-sepal` or `lein cirru-sepal watch`. Then you will see Clojure code compiled from Cirru code. It’s simple.

Here is a simple demo I tried to write Clojure with Cirru Sepal, well it look nice to me. Since this is a subset of Clojure, it’s actually far less powerful than Clojure is, but it’s OK with small projects:

There are a few tricky pieces in Cirru Sepal currently, like strings written in `|a` or `“|a blank b”` instead of `“a”` and `“a blank b”` being restricted by Cirru syntax. And `([] 1 2)` for `[1 2]`, `({} (:a 1) (:b 2))` for `{:a 1 :b 2}`. It’s currently merely a simply solution yet.

Probably I will write docs explaining the details behind Cirru Sepal Clojure as I use it more and more and it finally become handy one. Just at this moment I will leave that to you to explore and hope you like it.

--

--