Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-07-07 Thread Nahuel Greco
just for the record, it seems you can resolve CLJS vars at compile time to get their metadata by using (cljs.analyzer/resolve-var (dissoc env :locals) varsym) (thanks @w01fe*)* Saludos, Nahuel Greco. On Sat, May 31, 2014 at 12:43 PM, Nahuel Greco ngr...@gmail.com wrote: You already answered

Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-05-31 Thread Thomas Heller
Hey, not sure what you are trying to achieve, since the compiler should already warn you if a var is not found. Might not do so when nesting defs. def/defn are top level forms und should not be nested, especially no def in a defn. As for your question: the CLJS compiler supports vars in

Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-05-31 Thread Nahuel Greco
Thomas, this is an isolated test, the real case was creating a defmulti macro wrapper and a defmethod one, so in the mydefmulti macro I attach some metadata to the var defmulti defines and then I fetch it in the mydefmethod calls (by using resolve), all in compile-time. This works perfectly in the

Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-05-31 Thread Gary Trakhman
The key is in what you think you mean by 'available at compile-time'. How could this be the case? The macro system has no knowledge of the CLJS compiler internals, and the CLJS compiler does not try to project its state onto the clojure namespace system. However, CLJ macros can return symbols

Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-05-31 Thread Gary Trakhman
The other piece of the puzzle: cljs.core/resolve-var is in a CLJ namespace and uses compiler state: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/core.clj#L681 On Sat, May 31, 2014 at 10:10 AM, Gary Trakhman gary.trakh...@gmail.com wrote: The key is in what you think you

Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-05-31 Thread Nahuel Greco
Gary, maybe I'm misunderstanding you, but cljs.core/resolve-var doesn't contradict your the macro system has no knowledge of the CLJS compiler internals stance? What's the intent of that function (given that trying it in my original example doesn't seems to be capable of resolving the var)? It can

Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-05-31 Thread Gary Trakhman
Why are you bringing the built-in macro env into this? Cljs.core/resolve-var refers to this env: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/env.clj#L39 AFAIK there is no link between them (I could be wrong). On Sat, May 31, 2014 at 10:39 AM, Nahuel Greco ngr...@gmail.com

Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-05-31 Thread Gary Trakhman
We still have to consider that println won't work, even if it is possible to resolve the var, so you'll have to use some other method to see the data: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/compiler.clj#L897 On Sat, May 31, 2014 at 11:21 AM, Gary Trakhman

Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-05-31 Thread Nahuel Greco
You already answered the println question, now I'm using spit inside the macro instead of println, let's forget about it. Now the problem is to access CLJS vars at compile time from the macro, not printing them :) The issue seems to be reduced to the question if you can access the CLJS compiler

Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-05-30 Thread Nahuel Greco
I understand your point, but if you change the previous code to use fully qualified syms by changing (p.macros/check-var-at-compile-time *v1*) to (p.macros/check-var-at-compile-time p.core/v1)it stills doesn't work. Also doing (ns-resolve 'p.core 'v1) or (find-var 'p.core/v1) inside the macro

[ClojureScript] are Vars available for macros? Println from macros?

2014-05-29 Thread Nahuel Greco
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: ;;;

Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-05-29 Thread Gary Trakhman
#1, CLJS macros must use fully-qualified vars. It is possible to resolve using analyzer state, but that requires internal knowledge of the CLJS compiler. #2, it would be going to whatever the binding of *out* is in the current thread, likely it's ending up in the compiled CLJS source code because

Re: [ClojureScript] are Vars available for macros? Println from macros?

2014-05-29 Thread Gary Trakhman
Sorry, did I say Vars? I meant syms. On Thu, May 29, 2014 at 11:41 AM, Gary Trakhman gary.trakh...@gmail.comwrote: #1, CLJS macros must use fully-qualified vars. It is possible to resolve using analyzer state, but that requires internal knowledge of the CLJS compiler. #2, it would be going