Created by Andrew Scott
List Processing
(+ 2 4)
; => 6
(def example (list '+ (+ 1 1) (+ 2 2)))
; => (+ 2 4)
(eval example)
; => 6
(read-string "(+ 2 4)")
; => (+ 2 4)
(eval (read-string "(+ 2 4)"))
; => 6
(when (true) (println “hello”))
; => “hello”
(macroexpand ‘(when (true) (println “hello”)))
; (if (true) (do (println “hello”)))
(defmacro when
"Evaluates test. If logical true, evaluates body in an implicit do."
{:added "1.0"}
[test & body]
(list 'if test (cons 'do body)))
Functions | Macros |
---|---|
Execute at runtime | Execute at compile-time |
Take and produce data (values) | Take and produce code |
C#, Java, etc. | Clojure |
---|---|
Direct references to things that can change | Indirect references to thing that never change |
Concurrency is all convention, all manual | Concurrency semantics are built in |