I'm playing around in the REPL, I type in a function, I use it and
continue to work on other stuff... I can't remember what the function
looked like and I want to display the source of it again...
I know I can go back through the REPL history but maybe I typed it in
ages ago or maybe I typed it on multiple lines so it's hard to piece
together from the history. That seems like hard work.
I know I can go directly to the .jline-clojure.main.history file in my
home directory. That seems like cheating (and it means I have to jump
out of the REPL and hunt thru the file).
I know I can use (source sym) to get the source of something whose
.clj is on the classpath - that doesn't work for stuff typed directly
into the REPL.
Is there something easy within the REPL to show the source of
something you defined earlier?
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
> --
> 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
--
Moritz Ulrich
Programmer, Student, Almost normal Guy
http://www.google.com/profiles/ulrich.moritz
BB5F086F-C798-41D5-B742-494C1E9677E8
> I think this would be a very nice extension for the repl - Saving the
> forms for later-retrieval.
As precedent, the Common Lisp reader uses the +, ++, and +++ variables¹
to store the last three forms read.
Footnotes:
¹ http://www.lispworks.com/documentation/HyperSpec/Body/v_pl_plp.htm
--
Steven E. Harris
> Moritz Ulrich <ulrich...@googlemail.com> writes:
>
>> I think this would be a very nice extension for the repl - Saving the
>> forms for later-retrieval.
>
> As precedent, the Common Lisp reader uses the +, ++, and +++ variables¹
> to store the last three forms read.
An early draft of the current clojure repl included a feature like that. At the time it was judged not sufficiently useful to keep.
The clojure repl is very customizable. It's possible to add this feature in a custom repl to experiment with the idea:
(declare r1 r2 r3)
(defn saving-repl-read [request-prompt request-exit]
(let [r (clojure.main/repl-read request-prompt request-exit)]
(cond (#{request-prompt request-exit} r) r
(#{'+ '++ '+++} r) `(quote ~({'+ r1 '++ r2 '+++ r3} r))
:else (do (set! r3 r2) (set! r2 r1) (set! r1 r) r))))
(binding [r1 nil r2 nil r3 nil]
(clojure.main/repl :read saving-repl-read))
-------------
user=> 1
1
user=> (/ 22 7)
22/7
user=> (java.util.UUID/randomUUID)
#<UUID fd91090a-8336-4a32-91e2-2c49e114177a>
user=> ++
(/ 22 7)
user=>
-------------
Following the clojure repl's precedent of *1 *2 and *3, these might be better named +1 +2 and +3 if the idea gets any traction.
--Steve
Awesome. I'll see if I can generalize that to keep a longer history
and a nice easy way to view / retrieve past entries so I can see how
useful I'd actually find it in real life...
This weekend has been a journey through The Joy of Clojure. I read
about 100 pages on Friday evening (easy going), 150 pages on Saturday
(harder going - more complex topics). Today I read another 50 pages,
skipped chapters 11 & 12 (brain too full to process - about 80 pages)
and read chapter 13 (about 20 pages). All the time I had a REPL open
and kept copy'n'pasting examples in and playing with them to get a
feel for it. It's been a really fun weekend! Now, unfortunately, I
must get chores (and work!) done before the week starts.
See some of you at the JavaOne Clojure meetup tomorrow (Monday)?
--
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
So I'd say (file-repl "console.txt") and everything typed in and
printed out would be written to that file for the REPL session?
That would be a bit like the .jline-clojure.main.history file (but
would include all output as well).
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/