Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom data readers do not appear to be supported. #128

Open
ont-app opened this issue Jun 6, 2024 · 0 comments
Open

Custom data readers do not appear to be supported. #128

ont-app opened this issue Jun 6, 2024 · 0 comments

Comments

@ont-app
Copy link

ont-app commented Jun 6, 2024

I have defined a custom reader macro that is supported elsewhere in the cljs infrastructure, but does not work in the Cider REPL.

> #voc/lstr "gaol@en-uk"
Unexpected error (ExceptionInfo) compiling at (REPL:1).
failed compiling constant: gaol; ont_app.vocabulary.lstr.LangStr is not a valid ClojureScript constant.

It has been hypothesized that this code might fix the problem:

(defn read-cljs-string [form-str]
  (when-not (string/blank? form-str)
    (binding [*ns* (create-ns ana/*cljs-ns*)
              reader/resolve-symbol ana/resolve-symbol
              reader/*data-readers* (merge tags/*cljs-data-readers*
                                                   (ana/load-data-readers))  ;; <<<<< note this change
              reader/*alias-map*
              (apply merge
                     ((juxt :requires :require-macros)
                      (ana/get-namespace ana/*cljs-ns*)))]
      (reader/read {:read-cond :allow :features #{:cljs}}
                   (readers/source-logging-push-back-reader
                    (java.io.StringReader. form-str))))))

I cloned the project and attempted to try it, but ran into technical difficulties I couldn't resolve.

See this discussion on Slack for context:

https://clojurians.slack.com/archives/C0617A8PQ/p1717590636580699

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant