Just to follow up on this & a note for future reference: I could get my original macro to work in both dialects by just syntax quoting the passed in arguments and I've also pushed out a first release of the mini-library this is all meant for...
https://github.com/thi-ng/macromath/blob/master/index.org Thanks once more for the pointers! On 24 February 2014 15:10, David Nolen <dnolen.li...@gmail.com> wrote: > If I recall you are allowed to splice in references to Java objects so this > works out in Clojure. > > > On Sunday, February 23, 2014, Karsten Schmidt <i...@toxi.co.uk> wrote: >> >> Oh man, I really do have to spend some more quality time with >> macroexpand-1 to fully grok those "~'~" forms, and - thank you - that >> change does work indeed! But then why does my original version work in >> Clojure? A change in quoting usually only causes havok/failure, but >> here it doesn't seem to... >> >> Thanks again! K. >> >> >> On 23 February 2014 22:15, David Nolen <dnolen.li...@gmail.com> wrote: >> > I think your unquoting needs tweaking? >> > >> > (defmacro defmathop >> > "Constructs a macro to build inlined nested expressions with f applied >> > to inner pairs and f2 to combine results." >> > [name f f2] >> > `(defmacro ~name >> > ([a# b# c#] `(~'~f2 (~'~f ~a# ~b#) ~c#)) >> > ([a# b# c# d#] `(~'~f2 (~'~f ~a# ~b#) (~'~f ~c# ~d#))))) >> > >> > On Sunday, February 23, 2014, Karsten Schmidt <i...@toxi.co.uk> wrote: >> >> >> >> Thanks, David! I tried that already and it didn't work: >> >> >> >> clojure.lang.Compiler$CompilerException: >> >> java.lang.ClassNotFoundException: cljs.core, >> >> compiling:(macromath/macros.clj:58:1) >> >> >> >> I also tried to require cljs.core in that macro's namespace, but then >> >> it complains this way: >> >> >> >> clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: >> >> Can't take value of a macro: #'cljs.core/+, >> >> compiling:(macromath/macros.clj:59:1) >> >> >> >> Hmmm.... >> >> >> >> On 23 February 2014 19:52, David Nolen <dnolen.li...@gmail.com> wrote: >> >> > You shouldn't use js*, and in this case it can be avoided. The >> >> > problem >> >> > you're encountering is a long outstanding wart that ClojureScript >> >> > macros >> >> > resolve symbols in Clojure not ClojureScript. Instead of + (which is >> >> > actually clojure.core/+) you want to specify cljs.core/+: >> >> > >> >> > (defmathop cljs.core/+ cljs.core/+) >> >> > >> >> > >> >> > On Sun, Feb 23, 2014 at 2:47 PM, Karsten Schmidt <i...@toxi.co.uk> >> >> > wrote: >> >> >> >> >> >> After taking another look through cljs.core I managed to reformulate >> >> >> my macro using js* templates, but am still wondering why the >> >> >> "normal" >> >> >> (and cross-platform) solution doesn't work and also if using the js* >> >> >> way is actually safe in the future (i.e. not just a current >> >> >> implementation detail)? >> >> >> >> >> >> (defmacro defmathop >> >> >> "Constructs macro to build inlined nested expressions with f >> >> >> applied >> >> >> to inner pairs and f2 to combine results." >> >> >> [name f f2] >> >> >> `(defmacro ~name >> >> >> ([a# b# c#] >> >> >> (list '~'js* (str "((~{} " ~f " ~{}) " ~f2 " ~{})") >> >> >> a# b# c#)) >> >> >> ([a# b# c# d#] >> >> >> (list '~'js* (str "((~{} " ~f " ~{}) " ~f2 " (~{} " ~f " >> >> >> ~{}))") >> >> >> a# b# c# d#)))) >> >> >> >> >> >> (defmathop madd "*" "+") >> >> >> >> >> >> Thanks for any answers! >> >> >> >> >> >> On 23 February 2014 16:28, Karsten Schmidt <i...@toxi.co.uk> wrote: >> >> >> > Btw. My cljs example above is slightly wrong due to my simplifying >> >> >> > the >> >> >> > email >> >> >> > example. I originally used this ns declaration >> >> >> > >> >> >> > (ns macromath.test >> >> >> > (:require-macros [macromath.core :as m])) >> >> >> > >> >> >> > ...and then of course referred to (m/madd ...) >> >> >> > >> >> >> > But the issue remains regardless... >> >> >> > >> >> >> > On 23 Feb 2014 15:59, "Karsten Schmidt" <i...@toxi.co.uk> wrote: >> >> >> >> >> >> >> >> Hi, I've written a macro to build inline expanded math >> >> >> >> expressions >> >> >> >> and >> >> >> -- >> > 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. > > -- > 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.