Re: Macro writing macro fails with CLJS

2014-02-27 Thread Karsten Schmidt
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

Re: Macro writing macro fails with CLJS

2014-02-24 Thread David Nolen
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 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

Re: Macro writing macro fails with CLJS

2014-02-23 Thread Karsten Schmidt
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...

Re: Macro writing macro fails with CLJS

2014-02-23 Thread David Nolen
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#)

Re: Macro writing macro fails with CLJS

2014-02-23 Thread Karsten Schmidt
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$C

Re: Macro writing macro fails with CLJS

2014-02-23 Thread David Nolen
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

Re: Macro writing macro fails with CLJS

2014-02-23 Thread Karsten Schmidt
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)? (defma

Re: Macro writing macro fails with CLJS

2014-02-23 Thread Karsten Schmidt
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, "Kar

Macro writing macro fails with CLJS

2014-02-23 Thread Karsten Schmidt
Hi, I've written a macro to build inline expanded math expressions and it's working well in Clojure, however fails with a compile exception in CLJS. I'm not sure if this is a shortcoming of the CLJS compiler or (much more likely) a mistake with my macro. (ns macromath.core) (defmacro defmathop