I know ClojureScript doesn't support run-time Vars, but reading the CLJS
code I thought it supported Vars at compile-time, when all is executed
inside the CLJ/JVM runtime. The following code compiles without
assertexceptions for CLJ/JVM but when compiling CLJS the
assert in the macro fails:

;;; src/p/macros.clj ;;;
(ns p.macros)

(defmacro check-var-at-compile-time [v]
    (println "evaluating macro for" v)
    (assert (resolve v) (str "Var " v " not found at ns " *ns*)))

;;; src/p/core.clj - compiles ok;;;
(ns p.core [:require p.macros])

(def v1 3)
(p.macros/check-var-at-compile-time v1)

(defn foo []
    (def v2 4)
    (p.macros/check-var-at-compile-time v2))

;;; src-cljs/p/core.cljs - fails at compilation ;;;
(ns p.core [:require p.macros])

(def v1 3)
(p.macros/check-var-at-compile-time v1)

(defn foo []
    (def v2 4)
    (p.macros/check-var-at-compile-time v2))

In CLJ the vars are found and the println message is printed to the console
when you compile it using lein run or by requiring the ns at the REPL. In
CLJS the assertion fails in compile-time with "Assert failed: Var v1 not
found at ns p.core" and no println message is shown. So:

1- There is a way for macros to access compile-time Vars?
2- When you compile the CLJS code by using lein cljsbuild once, where the
println output from the macro at compile time is going? (a minor annoyance)

Saludos,
Nahuel Greco.

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

Reply via email to