Hi Konrad, yeah, I already saw that the k# is being unravelled in this version, but I don't understand why. Calling swizzle* with an existing deftype instance directly is working absolutely fine, just not when called from within the other macro. So my confusion remains about maybe needing somewhere another layer of syntax quoting? But where? But why?
Also, the keywords passed in to valAt/swizzle* would be in this case 3 chars long, e.g. :zyx, :xxy, : yyy - their role is basically to redefine the order of fields in the new instance... On 12 September 2013 07:58, Konrad Hinsen <googlegro...@khinsen.fastmail.net> wrote: > Karsten Schmidt writes: > > > Now, where things go wrong is when I try to use this swizzle macro > > from within the 2nd macro which generates the deftype skeleton (also > > stripped down): > ... > > > (defvec 3) > > CompilerException java.lang.IllegalArgumentException: No matching ctor > > found for class compile__stub.user.Vec3, > > compiling:(NO_SOURCE_PATH:1:1) > > > > =:_( > > > > I've been trying a lot of other versions (e.g. inline swizzle*, > > defining it as local fn etc.), but honestly I don't understand why > > this fails and would really appreciate some further insights into > > these aspects of the dark art of macro voodoo. > > Recursive macro expansion is an important debugging aid for macro writers: > > (use 'clojure.tools.macro) > (mexpand-all '(defvec 3)) > > returns > > (let* [] > (deftype* Vec3 user.Vec3 [x y z __meta__1154__auto__] > :implements [clojure.lang.IObj clojure.lang.ILookup > clojure.lang.IType] > (user/valAt [this__1155__auto__ k__1157__auto__] > (new Vec3 > (. this__1155__auto__ k) > (. this__1155__auto__ _) > (. this__1155__auto__ _) > (. this__1155__auto__ 1) > (. this__1155__auto__ 1) > (. this__1155__auto__ 5) > (. this__1155__auto__ 7) > (. this__1155__auto__ _) > (. this__1155__auto__ _) > (. this__1155__auto__ a) > (. this__1155__auto__ u) > (. this__1155__auto__ t) > (. this__1155__auto__ o) > (. this__1155__auto__ _) > (. this__1155__auto__ _) > __meta__1154__auto__)) > (clojure.core/meta [this__1155__auto__] __meta__1154__auto__) > (user/withMeta [this__1155__auto__ mm__1156__auto__] (new Vec3 x y z > mm__1156__auto__))) > (do (clojure.core/import* "user.Vec3")) > (def ->Vec3 (fn* ([x y z __meta__1154__auto__] (new user.Vec3 x y z > __meta__1154__auto__)))) > user.Vec3) > > So the problem is that your swizzle* macro takes apart the symbol > generated from k#. > > I suspect you want to pass a keyword such as :x to valAt at > runtime. In that case, you can't decompose it using a macro at compile > time. > > Konrad. > > -- > -- > 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 unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. -- Karsten Schmidt http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.