Created
August 16, 2010 19:08
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) | |
" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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