Fork me on GitHub
#clojure
<
2022-08-19
>
craftybones20:08:21

If I have a function ref in a config edn of some sort, is requiring-resolve the best way to resolve and use it? What is a good approach to eval fns that are specified in edn files?

craftybones20:08:54

ex:

{:fn-to-exec 'clojure.string/join}

p-himik20:08:58

If it's just a qualified symbol, then requiring-resolve should work. If it's a function definition, like (fn [x] (do-stuff x)), then you'll need to use eval.

craftybones20:08:16

no, not a fn . Just a symbol

Alex Miller (Clojure team)20:08:10

yes, requiring-resolve is a good thing to apply here

Alex Miller (Clojure team)20:08:15

this is actually a long-standing problem we've been talking about in the clojure team. most systems eventually have this need and we've been considering a standard tagged literal or something that could be resolved on read. like imagine #'foo/bar that reads as a real var (or #var foo/bar or something else)

👍 1
Alex Miller (Clojure team)20:08:23

otherwise you have to read edn, then apply some walk to resolve certain things back to fns/vars