clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
Jakub Holý 2021-04-11T07:52:33.075300Z

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!

thheller 2021-04-11T07:57:22.076100Z

@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

❤️ 2
dazld 2021-04-11T11:34:10.081200Z

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?

dazld 2021-04-11T11:36:32.082900Z

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.

dazld 2021-04-11T11:38:16.084400Z

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.

dazld 2021-04-11T11:38:56.085300Z

In other words, treat symbols as placeholders.

dazld 2021-04-11T11:40:04.085700Z

https://github.com/clj-pour/pour/blob/master/src/pour/compose.clj#L63 macro in question

dazld 2021-04-11T12:23:14.087500Z

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

thheller 2021-04-11T12:26:26.087700Z

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

dazld 2021-04-11T12:30:13.089500Z

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

thheller 2021-04-11T14:11:47.089700Z

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

dazld 2021-04-11T14:25:47.093200Z

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?

thheller 2021-04-11T14:41:09.099Z

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

👍 1
dazld 2021-04-11T14:41:33.099400Z

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