Fork me on GitHub
#tools-deps
<
2021-01-03
>
vlaaad20:01:34

Me, trying to be smart and sneak in read-eval to deps.edn: 1. creates data_readers.clj with {clj/eval clojure.core/eval} 2. creates alias with :key #clj/eval (requiring-resolve my-fn) in :exec-args clj_exec.clj: uses edn/read-string that ignores data_readers https://github.com/clojure/brew-install/blob/fde9db19bfe92a315b81b5f56d290a6d37a91d89/src/main/resources/clj_exec.clj#L39

vlaaad20:01:37

¯\(ツ)

vlaaad20:01:16

I think clj-exec is limiting by only accepting edn data. I want to pass a function, I don't want to add work-arounds that accept and auto-resolve symbols where exec function they expect functions as arguments

seancorfield20:01:02

@vlaaad Whilst I share some of that frustration (after hours poking at the internals of Figwheel, Rebel Readline, and the cljs compiler itself), I think it would pretty dangerous -- I think it is reasonable for the function you invoke to have to do the requiring-resolve because it's generally easy enough to write a wrapper that you can invoke (and have it invoke whatever you're trying to pass a function into).

vlaaad20:01:11

I agree that read-eval is probably too dangerous for a problem I don't have a solution for, but passing function to a function should not be impossible with clj-exec IMO

dpsutton21:01:47

What’s wrong with passing the fully qualified name? Don’t prepls repls and socket servers behave this way?

vlaaad21:01:39

clojure.main/repl expects functions, for example, so it can't be used from clj-exec

seancorfield21:01:58

Yeah, that was similar to my use case: where I want a resolved symbol, which has to happen at runtime, hence a wrapper is needed.

Alex Miller (Clojure team)21:01:26

We are working towards a solution to this greater problem

🙏 3
Alex Miller (Clojure team)21:01:05

In particular, making vars autoresolve on read

Alex Miller (Clojure team)21:01:50

Note, not symbols but vars

Alex Miller (Clojure team)21:01:24

A release or two ago we changed var deserialization to do that

Alex Miller (Clojure team)21:01:58

I took a pass at var resolution at that point as well but we decided to wait on it. That’s likely to be in scope for 1.11

vlaaad21:01:27

Upvoted! Thanks for detailed response

Alex Miller (Clojure team)21:01:25

You’re not crazy :). We’ve been thinking about this for years