Discovering methods

0 views
Skip to first unread message

Serge Wroclawski

unread,
May 26, 2009, 10:20:48 AM5/26/09
to Clojure Study Group Washington DC
This is either a question or rant. I'm not sure which yet.

I believe in the functional model, but it's causing me a problem-
which is that I've yet to find a way to be able to ask an object about
the functions that I can use with it.

What I mean is, if I were using Ruby (or Python), I could do:

1.<TAB>

and get back a list of methods that are associated with that object.

I don't see a way to ask Clojure the same thing. I have doubts if it's
even possible, since unless the methods specify the types they'd
accept, there'd be no way to know.

Thoughts?

- Serge

Luke VanderHart

unread,
May 30, 2009, 9:55:20 AM5/30/09
to Clojure Study Group Washington DC
You're right, this is one of the few drawbacks of a language as
dynamic as Clojure.

But if you think about it, it doesn't even really make sense for pure
Clojure code. The very notion of an "object" only crops up when you're
interfacing with Java.

There are emacs/slime plugins that do this for java classes, by the
way... but for instances... the editor has no way of even telling that
a symbol is a java object, or what it's class was if it is.

One thing that does alleviate the problem is to do most of your
development in a running REPL, when possible. You can prod around with
objects as you like, and even write some helper "exploratory" macros
(I think they may already be written) so you can just do (methods obj)
and it will print out a list of methods.

-Luke
Reply all
Reply to author
Forward
0 new messages