May 2018
Beginner to intermediate
290 pages
6h 43m
English
So there’s our answer: Clojure’s syntax is the way it is because it’s amphibious, equally at home representing code and data. Having a single text format along with a single in-memory representation of both code and data is not just elegant; it also has some serious practical advantages. For example, writing Clojure code-analysis tools is very straightforward. Need to read a file full of Clojure code? No problem:
| | (ns codetool.core |
| | (:require [clojure.java.io :as io])) |
| | |
| | (defn read-source [path] |
| | (with-open [r (java.io.PushbackReader. (io/reader path))] |
| | (loop [result []] |
| | (let [expr (read r false :eof)] |
| | (if (= expr :eof) |
| | result |
| | (recur (conj result expr))))))) |
Call read-source with the path to a Clojure ...
Read now
Unlock full access