Created
April 24, 2012 17:25
-
-
Save rplevy/2481715 to your computer and use it in GitHub Desktop.
string that can contain quotes (for reader-valid content only)
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
(defmacro qq [& body] | |
`(->> | |
(map (fn [s#] | |
(if (string? s#) | |
(format "\"%s\"" s#) (str s#))) | |
(quote ~body)) | |
(interpose " ") | |
(apply str))) | |
(defn myfn "docstring \"the normal way\" sort of a pain" [] ) | |
(defn ^{:doc (qq this docstring is "a little better")} myfn2 [] ) | |
;; and you can interpolate values | |
(qq this string is #=(+ 1 1) times "better") |
But it could be explicitly supported similar to Chas's macro...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually I just realized the interpolation is not really what it seems, because you mostly won't have the values you want at read time.
Fail:
(let [x 1](qq this string is #=%28+ x x%29 times))