Hello! given a clojuresecript vector stored into the global js var _vec
, why does _vec.constructor.name
in JS return ""
instead of something like "PersistentVector"
? Is there any other way to see that what clojure data structure it is?
(Use case: In my cljs code I actually ask for (type x)
which returns function (meta,cnt,shift,root,tail,__hash){ ...}
- which I know is a cljs vector but somehow type
does not pick it up so I am looking for alternative ways. This is for the purpose of error logging.) Thanks!
@holyjak the .cljs$lang$ctorStr
property (instead of .name
) should contain the full name in development builds. :advanced
will usually remove that, or definitely rename it
I've been trying to port a clj library to cljs, and part of it is a macro that uses resolve. When a macro is operating on cljs or cljc code, there’s no way to access either the metadata or the value of the var, even if it's in a cljc namespace?
Say, for example, an eql expression that has symbols that can be resolved to vars embedded in it. I’d like to inline those values at compile time.
Thinking the only way to do this is to convert those symbols to keywords at runtime, and match them up with some kind of map supplied when a function is invoked.
In other words, treat symbols as placeholders.
https://github.com/clj-pour/pour/blob/master/src/pour/compose.clj#L63 macro in question
you can use https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/analyzer/api.cljc#L200
Thanks, I tried that but it doesn't give me the values, sadly. Just the analyser meta data
well yes, the actual value only exists in JS at runtime so thats not accessible during compilation
Thought so. Thanks anyway. Quite a drawback this - wonder if compiling inside a js runtime instead of a jvm would help..
well self-host would have access to those things if you want to do that
Was just pondering this. When you say self host, just to be clear, you are thinking of compiling in the host environment..? Would every non jvm host have the same issue?
yes, self-host as in the the compiler running in the JS runtime
Wonder if there's a subset of the language that's safe to execute regardless of the compilation target.