Hi folks,

I'm attempting to define methods within the output of a macro. As
these are definitions for syntactic benefit more than anything else,
I'm using the unquote-quote trick for argument names, so that the
input body can refer anaphorically to known names (like "request").
Convention over configuration and all that.

E.g.,

(defmacro req-> [[state msg] & body]
  `(defmethod ~'do-request [Foo ~state ~msg]
     [~'arg1 ~'arg2 ~arg3]
     ~...@body))

to produce from

(req-> [:bar :baz]
  (do-stuff arg1 arg2 arg3))   ; we know about arg1 etc. in advance

the following:

(defmethod do-request [Foo :bar :baz]
  [arg1 arg2 arg3]
  (do-stuff arg1 arg2 arg3))


This is all working fine. The issue is in trying to attach type
metadata to the generated argument names, so that I can avoid
reflection. Type metadata from #^ is attached at read-time, and I
can't get it to stick through quote/unquote — I still get reflection
warnings from the method bodies, where my code refers to the non-
annotated values. I've tried including a with-meta form (which I
didn't expect to work, given what I've read about its purpose re the
compiler), and that doesn't work either.

To clarify, I'd like to have arg3 annotated with tag metadata,
declaring that it's a Bar.

Does anyone have either:

* A way to get this reader information into my macro expansion, or
* An analogue to Common Lisp's (declare (type Bar arg3)) ?

Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~
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
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