Skip to content

Instantly share code, notes, and snippets.

@gfredericks
Created August 10, 2012 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfredericks/3310866 to your computer and use it in GitHub Desktop.
Save gfredericks/3310866 to your computer and use it in GitHub Desktop.
amalloy-fn implementable
;; Special forms supported are if and let*
(defmacro amalloy-fn
[args expr]
(let [[lettings new-expr]
(currj.independence/refactor
(clojure.walk/macroexpand-all expr)
args)]
`(let [~@(apply concat lettings)]
(fn ~args ~new-expr))))
(macroexpand-1 '(amalloy-fn [x y]
(+ x
(- 13 (* 2 3))
(/ y (* 2 Math/PI)))))
;; (clojure.core/let
;; [G__3940 (- 13 (* 2 3)) G__3942 (* 2 Math/PI)]
;; (clojure.core/fn [x y] (+ x G__3940 (/ y G__3942))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment