Well, that's sort of wanting to eat the cake and have it. It's impossible to resolve a symbol where it isn't known where it came from, if any resolving is to take place, it must assume to be in the current namespace.
So yes, you're right; syntax-quote would work best here. Jonathan On Mon, May 9, 2011 at 5:41 PM, Simon Katz <nomisk...@gmail.com> wrote: > On Mon, May 9, 2011 at 16:21, Jonathan Fischer Friberg < > odysso...@gmail.com> wrote: > >> Q1 This macro captures the correct namespace: >> >> (defmacro new* [type-name-as-symbol & args] >> `(clojure.lang.Reflector/invokeConstructor >> (ns-resolve ~*ns* ~type-name-as-symbol) >> (to-array '~args))) >> > > Unfortunately that doesn't work -- it captures the namespace in which new* > is called, but that may not be where the symbol is actually written. > Consider this: > > (ns my-namespace > (:refer dynamic-new)) > > (defrecord MyRecord [a b c]) > > (defn instantiate-using-parameter [type-name-as-symbol] > (new* type-name-as-symbol 1 2 3)) > > (in-ns 'another-namespace) > (my-namespace/instantiate-using-parameter 'MyRecord) > => #:my-namespace.MyRecord{:a 1, :b 2, :c 3} > > Again, the use of syntax-quote would qualify the symbol in the right > namespace -- the one containing the source of the symbol. > > Simon > > -- > 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 > -- 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