(defmacro defobserver [slot types params & body] (assert (keyword? slot) "defobserver> slot should be a keyword.") (let [ftypes (concat types (take-last (- 3 (count types)) '(::tiltontec.modeller.cell-types/model js/object js/object))) fparams (concat params (take-last (- 4 (count params)) '(me new-value old-value c)))] `(defmethod tiltontec.modeller.observer/observe [~slot ~@ftypes][~'slot ~@fparams] ~@body)))
#_(:clj (defmacro defobserver [slot types params & body] (assert (keyword? slot) "defobserver> slot should be a keyword.") (let [ftypes (concat types (take-last (- 3 (count types)) '(::tiltontec.modeller.cell-types/model Object Object))) fparams (concat params (take-last (- 4 (count params)) '(me new-value old-value c)))] `(defmethod tiltontec.modeller.observer/observe [~slot ~@ftypes][~'slot ~@fparams] ~@body))))
#?(:clj Object :cljs js/object)
This is because the macros are expanded by Clojure so inside a macro, it always looks like :clj. Take a look at how Expectations gets around this:
https://github.com/jaycfields/expectations/blob/master/src/cljc/expectations/platform.cljc#L9-L21
I’d love to hear if there’s an “official” recommended way to deal with reader conditionals in macros used from ClojureScript?
Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
My next problem with .cljc (which is going very very well overall!) has to do with macros.
....snip
ps. I will try the old trick of having a helper defn with-defobserver and with-whatever to see if this is purely a macro interaction.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
(def obj #?(:clj Object :cljs js/Object))