I just "discovered" the "#=" reader macro from a post on Stackoverflow
and it solves a problem. How likely is this reader macro to become an
official (documented) part of the language? How about deprecated or
changed behavior?

I am trying to use Stuart Sierra's "do-template" inside a
"defprotocol" to declare multiple similar methods:

(defprotocol AProtocol
  (a-method [this])
  #=(do-template [name]
        `(~(symbol (str name "-method")) [`~this `~that])
        foo bar baz))

should expand to

(defprotocol AProtocol
  (a-method [this])
  (foo-method [this that])
  (bar-method [this that])
  (baz-method [this that]))

When I tried the "do-template" without the "#=" macro, the compiler
complained that I was redefining "do-template", so I need the "do-
template" expanded *before* the "defprotocol". Is there any other way?

Is the "do-template" correct to expand to what I need? I tried testing
it with "macroexpand" and "macroexpand-1", but got:

(do (clojure.core/seq (clojure.core/concat (clojure.core/list (symbol
(str foo "-method"))) (clojure.core/list (clojure.core/apply
clojure.core/vector (clojure.core/seq (clojure.core/concat
(clojure.core/list (quote user/this)) (clojure.core/list (quote user/
that)))))))) (clojure.core/seq (clojure.core/concat (clojure.core/list
(symbol (str bar "-method"))) (clojure.core/list (clojure.core/apply
clojure.core/vector (clojure.core/seq (clojure.core/concat
(clojure.core/list (quote user/this)) (clojure.core/list (quote user/
that)))))))) (clojure.core/seq (clojure.core/concat (clojure.core/list
(symbol (str baz "-method"))) (clojure.core/list (clojure.core/apply
clojure.core/vector (clojure.core/seq (clojure.core/concat
(clojure.core/list (quote user/this)) (clojure.core/list (quote user/
that)))))))))

Nice! :-).

Are my anaphora (`~this `~that) correct?

Thanks.

BTW, I am writing my first large (several KLOC) Clojure program using
Swing -- I need to set similar actionListeners on several JButtons
(mondayButton, tuesdayButton, etc.) and thought that "do-template"
would be the perfect tool.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to