Fork me on GitHub

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?


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


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


It creates dependencies between vars via their metadata


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


you could just do with a compiler pass same as Clojure


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)