Re: Pretty-print with metadata

2012-01-22 Thread Tom Faulhaber
Chris, nice use of custom dispatch! I can't claim all the credit for this mechanism. I based my work on the old XP system that has been used in Lisp since the eighties. Standing on the shoulders of giants, as it were. :) It's been on my list to respect *print-meta* in the regular pprint dispatch,

Re: Pretty-print with metadata

2012-01-20 Thread Chris Perkins
Good catch! I was about to add this to my personal toolkit of "generally useful random crap" (every programmer has one of those, right?). I'll make sure to cover that edge-case. Thanks. - Chris -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: Pretty-print with metadata

2012-01-20 Thread Cedric Greevey
Yeah, but it won't quite work if even the metadata has metadata. user=> (def x (with-meta {:b 1} (with-meta {:a 1} {:x 1}))) #'user/x user=> x {:b 1} user=> (meta x) {:a 1} user=> (meta (meta x)) {:x 1} The code above would leave out the metadata {:x 1} on {:a 1}, though it should display the m

Re: Pretty-print with metadata

2012-01-20 Thread Meikel Brandmeyer (kotarak)
Cool. :) Good to hear, that things are working. Nice to have around. Meikel -- 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 patie

Re: Pretty-print with metadata

2012-01-20 Thread Chris Perkins
By looking at pprint.clj, I have come up with something that seems to work. No "hacking" is necessary - the code in pprint is impressively clear and extensible. It's obviously designed to allow exactly this sort of extension to the printing mechanism. user> (defn ppm [obj] (let [orig-d

Re: Pretty-print with metadata

2012-01-20 Thread Meikel Brandmeyer (kotarak)
Hi, I don't know a built-in way. But that doesn't mean, that there isn't one. You could ask Tom Faulhaber directly. He did the pretty print stuff. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to

Re: Pretty-print with metadata

2012-01-20 Thread Chris Perkins
Thanks Meikel. So I guess from your reply that there is no built-in way to do this, right? The objects I'm trying to inspect can be deeply nested maps and vectors, and I want to see all the metadata - not just on the root object. I guess I would have to either re-implement some of the logic o

Re: Pretty-print with metadata

2012-01-20 Thread Meikel Brandmeyer (kotarak)
Hi, how about something like this? (defn pprint-with-meta [thing] (when (instanceof? IMeta thing) (print "^") (pprint (meta thing)) (print " ")) (pprint thing)) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To p

Pretty-print with metadata

2012-01-20 Thread Chris Perkins
Is there a way to pretty-print an object with its metadata? If I (set! *print-meta* true) at the REPL, I can see the metadata. If I use (pprint thing), I can see the structure much more easily. How can I do both? - Chris -- You received this message because you are subscribed to the Google