Question regarding abusing the inline mechanism (sorry Alex)
I want to apply inline conditionally, per namespace
Possible implementation: abuse inline-arities and dynamic vars
Since inline-arities is a function, I can, in theory, put any piece of code I want there, including one which inspects the environment
So if I have a (inline-in-ns! foo bar) I could intern a var *inline-here*, then at inline time resolve it in the current namespace and check its value.
Another challenge is inspecting the form
Bit disgusting but it works:
(intern *ns* '*inline-here* '#{bar})
(defn foo
{:inline (fn [x] x)
:inline-arities (fn [n]
(when-let [ih (ns-resolve *ns* '*inline-here*)]
(when (get (deref ih) 'foo)
(println 'inline)
(= n 1))))}
[x]
x)