While going over the changelog for Clojure 1.9.0 I found that it introduced a dynamic var named
clojure.core/*reader-resolver* which allows to:
*reader-resolver*to an impl of LispReader$Resolver to control the reader’s use of namespace interactions when resolving autoresolved keywords and maps.
I can see that
clojure.spec.alpha was introduced in this version along with more support for namespaced maps and
*reader-resolver* seems to provide a powerful feature. But even after going over the code in
LispReader.java where it is used (e.g. here), I’m still struggling to find a use case where I would need it (which I think it’s because I don’t fully understand its implications).
Therefore I was wondering if anyone has any examples or knows the rationale behind introducing the possibility to customise this resolution behavior.
(A Google search didn’t return any useulf results and neither did a search in the existing topics in this forum, although I might have missed something).
I found the following couple of messages in the Clojurians Slack logs that are related to this.
Message from borkdude mentioning that using
clojure.core/*reader-resolver*might help to avoid
clojure.repl/sourcefailing because an auto-resolved keywords that use alias can’t be reoslved by the reader.
Message from boogie666 mentioning that they had to bind
clojure.core/*reader-reaolver*to be able to read in and analyse a file.
Based on these two examples (which are the only ones I could find), it seems that
clojure.core/*reader-reaolver* is bound to be used when reading a form with auto-resolved keywords that would only work at compile-time otherwise.
Is this understanding correct?