What about something like

;; obj.cljc
(ns obj)

(def obj #?(:clj Object :cljs js/Object))

(defmacro get-obj []
  `obj)

;; obj-test.cljc
(ns obj-test
  (:require [obj :refer-macros [get-obj]]))

(def gotten-obj (obj/get-obj))

Load obj-test in clj, and obj-test/gotten-obj is Object. Load it in cljs,
and gotten-obj is js/Object. Thus, you can write cljc macros that
symbolically refer to obj/obj and turn out as the correct thing. This is
because the macro doesn't refer to the *value* of obj, just to the symbol,
which isn't evaluated until runtime.

-- Dan Burton

On Fri, May 20, 2016 at 11:22 AM, hiskennyness <kentil...@gmail.com> wrote:

> Thanks, Sean. (My follow-up fix request went out just as your fix came in.)
>
> -kt
>
>
> On Friday, May 20, 2016 at 2:16:47 PM UTC-4, hiskennyness wrote:
>>
>>
>>
>> On Friday, May 20, 2016 at 1:34:43 PM UTC-4, hiskennyness wrote:
>>>
>>> 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.
>>>
>>
>> Not surprisingly, that worked on the second (unposted) example which
>> could be divided/conquered into a helper defn (tho my CL is getting rusty,
>> the old trick is  call-with-whatever).
>>
>> Unfortunately the other case (the one shown) really is a conditional
>> code-rewriting that has to happen at macroexpansion time, so a fix is still
>> needed.
>>
>>
>> --
> 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.
>

-- 
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