Fork me on GitHub
#clojurescript
<
2021-01-12
>
g7s19:01:40

As I understand a var's metadata is statically determined at compile-time so I was thinking that if I passed to a var's metadata another var that would be OK but this is not the case apparently. For example if I do

(defn foo [a] a)
(defn bar {:foo #'foo} [a] a)
then the (:foo (meta #'bar)) will not be the #'foo var but instead the unevaluated form (var foo). It seems that I cannot do this even at runtime because a var's metadata cannot be altered. Is there any other way I could do this?

dnolen19:01:44

there is no way around var metadata being statically determined, if you're trying to figure out a way around that - it isn't possible

g7s19:01:14

I wasn't trying actually to figure out a way around it but instead to figure out a way to point from one var to another, but I guess there is no easy way to do this in cljs

g7s19:01:23

It creates dependencies between vars via their metadata

dnolen20:01:51

@g7s why do you need to do that with var metadata?

dnolen20:01:06

you could just do with a compiler pass same as Clojure

g7s21:01:19

Hmm I am not sure what you mean. To give you some context I am building something that involves a compiler and I was copying the code (with some changes) to use it in my project that should work in both cljs and clj. I don't know how familiar you are with this code but it works by analysing the var metadata of every pass and then it tries to perform as few passes as possible (by combining passes that can be coombined)