Hi, Am 26.06.2009 um 16:39 schrieb Michele Simionato:
That means that I do not need gensym, I can just add a `#` to the identifiers I want to introduce hygienically, right? I guess this is what you meant by autogensym in the other post. A pretty cool idea, actually.
Exactly, here a short real-world example.
(defmacro with-out-str
[& body]
`(let [out-string# (StringWriter.)]
(binding [*out* out-string#]
~...@body)
(.toString out-string#)))
This macro is 100% hygienic. Things like
binding or StringWriter are resolved to the
binding and StringWriter in effect, when the
macro was defined. Also out-string# generates
a new local which does not clash with the
user code injected via ~...@body.
I think this is a very easy way to write macros.
It is almost a visual template of the final code.
Note: I didn't investigate whether there is
a StringWriter and what it's interface is. The
point of the example is the macro...
Sincerely
Meikel
smime.p7s
Description: S/MIME cryptographic signature
