Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to clojure.contrib's show?

There used to be this useful utility called show in clojure.contrib. Now, that it's deprecated, is there an equivalent to it?

Thanks!

like image 217
konr Avatar asked Jul 30 '13 19:07

konr


2 Answers

De-constructing show to be more "simple", making available distinct pieces of re-usable functionality, was discussed by Stuart Halloway in a talk he give on clojure simplicity.

The resulting code makes use of clojure.reflect/reflect and clojure.pprint/print-table and standard clojure filter:

(require 'clojure.reflect)
(require 'clojure.pprint)

(->> (clojure.reflect/reflect java.lang.String)
     :members
     (filter #(.startsWith (str (:name %)) "last"))
     (clojure.pprint/print-table))
like image 121
Alex Stoddard Avatar answered Oct 18 '22 03:10

Alex Stoddard


I refer you to the Where Did Clojure.Contrib Go document, which says about clojure.contrib.repl-utils:

Migrated to clojure.repl and clojure.java.javadoc. show functionality similar to clojure.reflect/reflect.

The clojure.reflect API documentation is here, and the clojuredocs.org examples are here.

like image 25
Jeremy Avatar answered Oct 18 '22 05:10

Jeremy