On Monday, December 28, 2015 at 10:49:19 PM UTC+1, Mike Fikes wrote: > Yes, this is because the underlying function that implements a macro take two > extra hidden arguments associated with the &env and &form special variables. > These are implicitly passed when a macro is consumed from a namespace that > does :require-macros to access the macro, but not when you consume a macro in > the same compilation stage where it was defined (a pattern that is supported > in Clojure, but not ClojureScript). > > To experiment with macros in REPLs like clojurescript.io—where you can't use > :require-macros for custom macros you are defining—I usually play games with > the compiler, defining and invoking macros in a way that is **unsupported**, > but nevertheless successfully violates the compiler's abstractions. See: > http://blog.fikesfarm.com/posts/2015-09-07-messing-with-macros-at-the-repl.html > > > > On Dec 28, 2015, at 1:16 PM, Zubair Quraishi <[email protected]> wrote: > > > > I tried the clojurescript.io on Chrome as well, and see the following with > > defmacro: > > > > cljs.user=> (defmacro somemacro [] 5) > > true > > cljs.user=> (somemacro ) > > Wrong number of args (0) passed to cljs.user/somemacro at line 1 > > cljs.user=> (somemacro) > > Wrong number of args (0) passed to cljs.user/somemacro at line 1 > > cljs.user=> (somemacro 1) > > Wrong number of args (1) passed to cljs.user/somemacro at line 1 > > cljs.user=> (somemacro 2) > > Wrong number of args (1) passed to cljs.user/somemacro at line 1 > > cljs.user=> > > > >> On Monday, December 28, 2015 at 3:29:30 PM UTC+1, Mike Fikes wrote: > >> Hi Zubair, > >> > >> It works in clojurescript.io on iPhone Safari. > >> > >> But, it would be interesting to separate the macro use from the alert. > >> > >> (The macro is incorrectly being used directly in the same compilation > >> stage where it is being defined—instead it needs to be separately brought > >> in via :require-macros). > >> > >> See: > >> https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#macros > >> > >> - Mike > >> > >> > >>> On Dec 28, 2015, at 8:54 AM, Zubair Quraishi <[email protected]> wrote: > >>> > >>> I've noticed that the following bootstrapped Clojurescript works in > >>> Chrome and Firefox using eval, but not on Webkit browsers such as iPhone, > >>> Safari, iPad: > >>> > >>> (ns some-namespace) > >>> > >>> (defmacro some-macro [& more] 5 ) > >>> (js/alert (pr-str (some-macro 1))) > >>> > >>> It should alert 5 on the screen but in Webkit the browser crashes. I've > >>> tested in Clojurescript 1.7.189 and 1.7.170 > >>> > >>> Anyone experienced anything similar? > >>> > >>> -- > >>> Note that posts from new members are moderated - please be patient with > >>> your first post. > >>> --- > >>> You received this message because you are subscribed to the Google Groups > >>> "ClojureScript" group. > >>> To unsubscribe from this group and stop receiving emails from it, send an > >>> email to [email protected]. > >>> To post to this group, send email to [email protected]. > >>> Visit this group at https://groups.google.com/group/clojurescript. > > > > -- > > Note that posts from new members are moderated - please be patient with > > your first post. > > --- > > You received this message because you are subscribed to the Google Groups > > "ClojureScript" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to [email protected]. > > To post to this group, send email to [email protected]. > > Visit this group at https://groups.google.com/group/clojurescript.
Ok thanks, that article made me understand the cljs macros much better and explains why I got that message, thanks! I think what I will do is make a minimal use case for the issue I was facing and put it up on github, as then it makes it easy to reproduce. Thanks for you time so far Mike, really appreciated, especially over the holidays! :) -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/clojurescript.
