Am I right that the following reflects a difference in Clojure macros from 
Common Lisp macros, and if so, am I missing a workaround?

The context is my trying to create a cljs wrapper for the qooxdoo js 
library, leveraging my model/cell dataflow framework written in all cljc. 
It is going well and now I want to do some syntactic sugar, some of it 
requiring macrology to defer evaluation.

uh-oh. Macros in cljs! Not a problem, I will just put them in a cljc 
dedicated to these do I do not have to make any more code than necessary 
cljc compatible.

Here is the full file with the problem:

(ns tiltontec.qxia.macros)

(defmacro hbox [[& hbox-args] & kids]
  `(tiltontec.qxia.core/qx-make
     ::tiltontec.qxia.base/m.Composite
     :layout (new js/qx.ui.mobile.layout.HBox)
    ~@hbox-args
    :kids (c?kids ~@kids)))

Here is the error:

> Reloading Clojure file "/tiltontec/qxia/macros.cljc" failed.
>
> clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: 
>> Invalid token: ::tiltontec.qxia.base/m.Composite, 
>> compiling:(tiltontec/qxia/macros.cljc:5:0)
>
> My understanding is that clj is somehow doing more than just the symbolic 
manipulation to which I am accustomed with CL macros, such that it is 
getting upset about not knowing the defined type.

I got clever and tried the same trick we use for deliberate variable 
capture ~'tiltontec.qxia.base/m.Composite but the compiler saw thru my 
little ruse and produced the same error.

Solution: I broke the types out of qxia.base.cljs into qxia.types.cljc so I 
would not have to make the whole base.cljs compatible with cljc:

(ns tiltontec.qxia.macros
  (:require [tiltontec.qxia.types]))

(defmacro hbox3 [[& hbox-args] & kids]
  `(tiltontec.qxia.core/qx-make
     ::tiltontec.qxia.types/m.Composite
     :layout (new js/qx.ui.mobile.layout.HBox)
    ~@hbox-args
    :kids (tiltontec.model.family/c?kids ~@kids)))

-kt

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to