My next problem with .cljc (which is going very very well overall!) has to
do with macros.
Should I mention that I am building under Figwheel? This toolchain stuff
has this old Lisper's head spinning.
Without a conditional, code using this macro compiles fine (the key bit
being where I offer devs a little syntactic sugar in coding up defobserver
so they can omit the dispatching types js/object (which I myself rarely
specify):
(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)))
But on clj those need to be Object. So I tried this (after wrapping the
above in #?(:cljs ...):
#_(: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))))
And in fact, that was a brave attempt to salvage my original attempt, which
conditionalized just the types:
#?(:clj Object :cljs js/object)
I repeated that twice, but just realized this would have been a good spot
for the splicing variant.
Anyway, no matter what I do I get a warning compiling to cljs that Object
is unknown, and indeed a macroexpand-1 of '(defobserver :fu [nil][_ _ _ _]
42) shows Object where I should be seeing js/object.
I am also getting the same problem with an unrelated macro in which I am
trying to conditionalize between dosync and do. Interestingly, I just
noticed the same macro conditionally chooses between Exception. and
js/Error. and I am not seeing warnings there!
Is this another known issue?
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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.