Skip to content

Instantly share code, notes, and snippets.

@francescoagati
Created August 16, 2010 19:08
Show Gist options
  • Save francescoagati/527541 to your computer and use it in GitHub Desktop.
Save francescoagati/527541 to your computer and use it in GitHub Desktop.
n example of with-diret-linking for overloading symbols in a local scope in clojure
(comment
"an example of with-diret-linking for overloading symbols in a local scope"
)
(ns prova.core)
(use 'clojure.contrib.macro-utils)
(require '[prova.over :as over])
(require '[clojure.contrib.macros :as macros])
(defmacro rewrite [form]
`(macros/with-direct-linking [over/+] ~form)
)
(println
(mexpand-all
'(rewrite
(+ 3 3)
)
)
)
(comment
"result
(let* [+ prova.over/+] (+ 3 3))
"
)
(ns prova.over)
(defn + [a b]
(- a b)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment