"Marshall T. Vandegrift" <llas...@gmail.com> writes:

Hi Marshall,

>> I'm facing the same issue.  I have this macro for java interop:
>>
>> (defmacro with-traversal-context
>>   [[g tc] & body]
>>   `(let [old-tc# (.getTraversalContext ^Graph ~g)]
>>      (try
>>        (.setTraversalContext ^Graph ~g ^TraversalContext ~tc)
>>        ~@body
>>        (finally (.setTraversalContext ^Graph ~g ^TraversalContext 
>> old-tc#)))))
>>
>> But the type hints are gone in the macro expansion, thus I have 3
>> reflection warnings per macro application, and real, performance
>> critical reflection warnings get lost in the shuffle.
>
> What you appear to be having is actually the different, but
> conceptually-related problem of the metadata reader macro and unquote
> operations interacting in a way which is consistent, but potentially
> not optimal.  Fortunately in your sort of situation, you can work
> around the problem by replacing the metadata reader macro with
> explicit metadata operations.

Yes, that would probably do the trick.  But on IRC, Alan already gave me
this recipe (gensyming the given parameter g) which is even a bit
shorter.

--8<---------------cut here---------------start------------->8---
(defmacro with-traversal-context
  [[g tc] & body]
  `(let [^Graph g# ~g
         ^TraversalContext old-tc# (.getTraversalContext g#)]
     (try
       (.setTraversalContext g# ~tc)
       ~@body
       (finally (.setTraversalContext g# old-tc#)))))
--8<---------------cut here---------------end--------------->8---

-- 
(What the world needs (I think) is not
      (a Lisp (with fewer parentheses))
      but (an English (with more.)))
Brian Hayes, http://tinyurl.com/3y9l2kf

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