Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure macroexpand

Tags:

macros

clojure

Why does

(macroexpand '(.. arm getHand getFinger))

expand to

(. (. arm getHand) getFinger)

while

(macroexpand '(-> arm getHand getFinger))

expands to

(getFinger (clojure.core/-> arm getHand))

In other words, why is the -> not expanding fully in the second example?

like image 212
Ralph Avatar asked Nov 29 '10 13:11

Ralph


1 Answers

macroexpand only expands the form until the symbol in the function position is not a macro. The reason why you notice this in the case of -> is because the -> macro is recursive.

In your case, you want macroexpand-all form clojure.walk

like image 89
Brian Avatar answered Sep 22 '22 15:09

Brian