To save the REPL and to see some definition, is it possible?

7 views
Skip to first unread message

LuizSiqueiraNeto

unread,
Oct 18, 2010, 1:35:36 PM10/18/10
to Clojure Study Group Washington DC
I have 2 questions:

1 - Is it possible save the REPL state?
2 - Suppose that I made a function and now I want change it or just
see your definition, Is it possible to list or see a function
definition on REPL, something like DIR?

Thanks

Craig Andera

unread,
Oct 18, 2010, 2:45:13 PM10/18/10
to clojure-...@googlegroups.com
> 1 - Is it possible save the REPL state?

If you're thinking of something like save-lisp-and-die from CL, then no.

> 2 - Suppose that I made a function and now I want change it or just
> see your definition, Is it possible to list or see a function
> definition on REPL, something like DIR?

You can find function definitions with (find-doc) and the various ns
utilities, but you're not going to be able to get the source, as it is
compiled away and Clojure knows nothing about it.

Both of these make a pretty good case for doing what Rich does, and
using SLIME, hacking in a buffer called tmp.clj, and evaluating
interactively to the REPL rather than typing directly in it.

LuizSiqueiraNeto

unread,
Oct 19, 2010, 9:48:50 AM10/19/10
to Clojure Study Group Washington DC
Where can I find information about the Rich idea?

Thanks

Craig Andera

unread,
Oct 19, 2010, 10:06:25 AM10/19/10
to clojure-...@googlegroups.com
> Where can I find information about the Rich idea?

It's not something I've seen documented anywhere. But it's a handy
technique. Basically, you open a file in emacs called whatever you
want. I call mine tmp.clj. Then you type commands there instead of in
the REPL, and use either C-x C-e (slime-eval-last-sexp) or C-M-x
(slime-eval-defun) to evaluate the expressions in the tmp.clj buffer
into the REPL.

This has two benefits: First, you have history, so it's easy to go
back and do what you did before [1]. Second, you have all the benefits
of the editor when you're authoring your commands, like paredit, if
you're a paredit sort of person.

[1] Now that I think about it, I believe there's a way to save the
command history from the REPL. Not the same thing as
save-lisp-and-die, of course.

Reply all
Reply to author
Forward
0 new messages