When *print-length* and *print-level* are set the forms printed are not 
always parseable as EDN. See this example:


(require 'clojure.edn)
(clojure.edn/read-string (pr-str {:a 1 :b 2 :c 3 :d 4}))
=> RuntimeException Map literal must contain an even number of forms


This occurs because the value printed is "{:a 1, :b 2, :c 3, ...}". I 
haven't been able to come up with a good solution for this. A description 
of the use case may help you understand the requirements. 

I'm working on a Clojure IDE/REPL for the Atom editor called Proto REPL 
<https://github.com/jasongilman/proto-repl>. When Proto REPL evaluates a 
form and gets a response it parses it using ClojureScript so that the value 
could be pretty printed, displayed in a tree structure, or visualized. The 
response returned from nREPL must be parseable as EDN. If the print-length 
isn't set then evaluation will hang while it tries to print out an infinite 
or extremely large data structure. When print-length is set then I get 
errors like the one above.

I've considered wrapping the code that the user's executing in something 
that will walk the structure and remove elements from the results but that 
has side effects on the values returned from the REPL. If they use *1 to 
access the last value it won't be the value they expect. Another option 
might be custom nREPL middleware to change how things are printed. Finally 
I'm wondering if it might be easier just to write a custom EDN parser in 
ClojureScript that could detect "..." in maps or other cases and handle 
appropriately. I wanted to avoid shaving any yaks if there's an easier 
solution.

If anyone else knows how other development environments like CIDER handle 
this I'd appreciate some suggestions.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to