No show?

281 views
Skip to first unread message

Ken Restivo

unread,
Feb 7, 2012, 5:14:53 PM2/7/12
to clo...@googlegroups.com
Hi all,

I'm curious why the "show" function got abandoned when migrating from monolithic
contrib.repl-utils to clojure.repl?

http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

It looks like it would have been useful. Does anything replace it?

Thanks.

-ken

Stuart Sierra

unread,
Feb 8, 2012, 5:19:01 PM2/8/12
to clo...@googlegroups.com
clojure.reflect/reflect gets you the same information as a big 'ole data structure. You can pprint it for readability.

The only thing that was not ported was the formatted text output, which would be easy enough to reproduce based on `reflect`.

-S

Stuart Halloway

unread,
Feb 9, 2012, 10:41:31 AM2/9/12
to clo...@googlegroups.com
clojure.reflect/reflect gets you the same information as a big 'ole data structure. You can pprint it for readability.

The only thing that was not ported was the formatted text output, which would be easy enough to reproduce based on `reflect`.

In particular, reflect + clojure.pprint/print-table.

Stu


Stuart Halloway
Clojure/core
http://clojure.com

Ken Restivo

unread,
Feb 11, 2012, 4:35:02 AM2/11/12
to clo...@googlegroups.com
On Thu, Feb 09, 2012 at 11:41:31AM -0400, Stuart Halloway wrote:
> > clojure.reflect/reflect gets you the same information as a big 'ole data structure. You can pprint it for readability.
> >
> > The only thing that was not ported was the formatted text output, which would be easy enough to reproduce based on `reflect`.
>
> In particular, reflect + clojure.pprint/print-table.
>

=> (require 'clojure.reflect)
nil
=> (require 'clojure.pprint)
nil
=> (clojure.pprint/print-table (clojure.reflect/reflect Math))
ClassCastException clojure.lang.Keyword cannot be cast to java.util.Map$Entry clojure.lang.APersistentMap$KeySeq.first (APersistentMap.java:132)

But reflect is useful enough just as a map, so problem solved, thanks!

-ken

Michał Marczyk

unread,
Feb 11, 2012, 9:30:45 PM2/11/12
to clo...@googlegroups.com
On 11 February 2012 10:35, Ken Restivo <k...@restivo.org> wrote:
> => (clojure.pprint/print-table (clojure.reflect/reflect Math))
> ClassCastException clojure.lang.Keyword cannot be cast to java.util.Map$Entry  clojure.lang.APersistentMap$KeySeq.first (APersistentMap.java:132)

print-table expects a sequence of maps, e.g.

(print-table (:members (reflect Math)))

or

(print-table (:members (reflect Math :ancestors true)))

to include inherited members.

Sincerely,
Michał

Sean Corfield

unread,
Feb 11, 2012, 10:15:24 PM2/11/12
to clo...@googlegroups.com
On Sat, Feb 11, 2012 at 6:30 PM, Michał Marczyk
<michal....@gmail.com> wrote:
> print-table expects a sequence of maps, e.g.
>
> (print-table (:members (reflect Math)))

Wow! I had no idea how useful that could be... Learn something new
every day! (and, lately, that's a new Clojure function every day...)
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

John Szakmeister

unread,
Feb 12, 2012, 4:29:30 PM2/12/12
to clo...@googlegroups.com
On Sat, Feb 11, 2012 at 10:15 PM, Sean Corfield <seanco...@gmail.com> wrote:
> On Sat, Feb 11, 2012 at 6:30 PM, Michał Marczyk
> <michal....@gmail.com> wrote:
>> print-table expects a sequence of maps, e.g.
>>
>> (print-table (:members (reflect Math)))
>
> Wow! I had no idea how useful that could be... Learn something new
> every day! (and, lately, that's a new Clojure function every day...)

That is amazing! Thanks for the tip Michał!

-John

Asim Jalis

unread,
Dec 11, 2012, 10:39:47 AM12/11/12
to clo...@googlegroups.com
This is a good workaround—however, I still wish repl-utils/show was still there. It was nice to always have it there instead doing this defn every time I need it to explore a Java API.

On Sat, Feb 11, 2012 at 6:30 PM, Michał Marczyk <michal....@gmail.com> wrote:

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply all
Reply to author
Forward
0 new messages