Reputation: 301
If I run this code
(defmacro foo
[expr]
(println "expr:" expr))
(foo '(1 2 3))
I will get the following print message
expr: (quote (1 2 3))
but I want to get the following message
expr: '(1 2 3)
I want to handle original reader macro string (before transformed) in defmacro. Maybe, I will access the string by reading a file which the macro is used and parse it, but not so cool. Please let me know if you know a much better way to do the mentioned above.
Thanks in advance.
Upvotes: 1
Views: 77
Reputation: 3074
according to http://www.clojure.org/reference/reader
The behavior of the reader is driven by a combination of built-in constructs and an extension system called the read table.
and
The read table is currently not accessible to user programs.
so I'd say no. Which is consistent with what I remember from various clojure books.
One thing which seemingly can be preserved are reader-conditionals
(read-string
{:read-cond :preserve}
"[1 2 #?@(:clj [3 4] :cljs [5 6])]")
;; [1 2 #?@(:clj [3 4] :cljs [5 6])]
Upvotes: 2