On Saturday, October 18, 2014 7:37:54 PM UTC-7, Dom Kiva-Meyer wrote: > You are resolving the protocol method symbol. > > `(-invoke ...) expands to (your.namespace/-invoke ...) > > > To fix this, you need to quote (not syntax-quote) and unquote the symbol. > `(~'-invoke ...) expands to (-invoke ...) > > > Make liberal use of clojure.core/macroexpand, clojure.core/macroexpand-1, and > clojure.walk/macroexpand-all when writing macros. > > > > > On Sat, Oct 18, 2014 at 4:58 PM, Russell Dunphy <[email protected]> > wrote: > I'm having real difficulty trying to write a macro that creates a defrecord > which implements certain protocols in Clojurescript. > > > > I've created a minimal example project that shows the problem I'm having at > https://github.com/rsslldnphy/cljs-protocols-in-macros > > > > The example has two records, one created with a plain defrecord that > implements IFn, the other that does exactly the same but in a macro. The > plain defrecord works as expected, but the one created in a macro doesn't - > it's not callable as a function. > > > > Weirdly it returns true for (ifn?) however. Looking at the js console > (screenshot in the repository) the macro created record seems to have a value > of `true` in its __proto__ map for cljs.core.IFn (whereas all the other > entries in the __proto__ map are functions, and the plain defrecord has > function entries for the different arities of `invoke`). > > > > I'm lost at this point (and new to Clojurescript). Am I doing something > wrong? Is this even possible? > > > > Thanks, > > > > Russell > > > > -- > > 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 http://groups.google.com/group/clojurescript.
Be aware that if you rely on clojure.core/macroexpand-1, etc. you may run into issues with certain forms. To be on the safe side I recommend keeping cljs.analyzer/macroexpand-1 in mind too as it will give you the ClojureScript expansion which, in some cases, is different. -- 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 http://groups.google.com/group/clojurescript.
