Fork me on GitHub
#clojurescript
<
2021-04-11
>
Jakub Holý (HolyJak)07:04:33

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!

thheller07:04:22

@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

❤️ 6
dazld11:04:10

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?

dazld11:04:32

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.

dazld11:04:16

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.

dazld11:04:56

In other words, treat symbols as placeholders.

dazld12:04:14

Thanks, I tried that but it doesn't give me the values, sadly. Just the analyser meta data

thheller12:04:26

well yes, the actual value only exists in JS at runtime so thats not accessible during compilation

dazld12:04:13

Thought so. Thanks anyway. Quite a drawback this - wonder if compiling inside a js runtime instead of a jvm would help..

thheller14:04:47

well self-host would have access to those things if you want to do that

dazld14:04:47

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?

thheller14:04:09

yes, self-host as in the the compiler running in the JS runtime

👍 3
dazld14:04:33

Wonder if there's a subset of the language that's safe to execute regardless of the compilation target.