Is there a way to stop a long running expression in the REPL

403 views
Skip to first unread message

Cecil Westerhof

unread,
Feb 21, 2015, 6:45:40 AM2/21/15
to clo...@googlegroups.com
Sometimes I execute something that takes to long. With <Ctrl>-C I can cancel it, but this also cancels the REPL itself. Is there a way to terminate the running command without terminating the running REPL?

--
Cecil Westerhof

Lucas Bradstreet

unread,
Feb 21, 2015, 7:28:57 AM2/21/15
to clo...@googlegroups.com
Which repl are you using? In lein repl, this does not happen to me, it
just terminates the expression.
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Cecil Westerhof

unread,
Feb 21, 2015, 7:40:14 AM2/21/15
to clo...@googlegroups.com
2015-02-21 13:28 GMT+01:00 Lucas Bradstreet <lucasbr...@gmail.com>:
Which repl are you using? In lein repl, this does not happen to me, it
just terminates the expression.

​I am using:
    rlwrap java -cp "${CP}" clojure.main --init "${CLOJURE_INIT}" --repl

But maybe it is time to switch. ;-)​
 
 
On 21 February 2015 at 19:45, Cecil Westerhof <cldwes...@gmail.com> wrote:
> Sometimes I execute something that takes to long. With <Ctrl>-C I can cancel
> it, but this also cancels the REPL itself. Is there a way to terminate the
> running command without terminating the running REPL?
 
--
Cecil Westerhof

Fluid Dynamics

unread,
Feb 21, 2015, 8:59:33 AM2/21/15
to clo...@googlegroups.com
It depends on what REPL/IDE you are using. In Counterclockwise there's an icon on the REPL pane's upper right with a red box near a gear, third from the left, which interrupts the currently running expression. Some other REPL environments provide similar functionality, as other people have noted in this thread, while others unfortunately don't provide a way short of restarting the REPL (and losing anything you've def'd or defn'd at the REPL in the process -- it's a good idea to keep a scratch file in Notepad or somewhere and paste things there that don't belong in your source code but which are convenient to run from time to time in the REPL, such as ad hoc tests or convenience functions and defs for during development).

Lee Spector

unread,
Feb 21, 2015, 10:42:37 AM2/21/15
to clo...@googlegroups.com

In case anybody is developing tools for this kind of thing, one of the things I most miss from Common Lisp is the ability to interrupt a running expression AND see the values of locals at the point of interruption. Fantastically useful for debugging. As far as I know there's no environment that lets you do this for Clojure. Seeing locals at the context of an exception (for each stack frame) is also fantastically useful and at the top of my wish list for the ecosystem... and while I've heard tell that there's a way to do this (Ritz?) if you run within emacs, I've never actually seen this in action and would love it if there was a more broadly accessible way to do this.

-Lee

Shawn Rasheed

unread,
Feb 21, 2015, 3:02:07 PM2/21/15
to clo...@googlegroups.com
If it's the clojure repl this might work: https://clojuredocs.org/clojure.repl/set-break-handler!
--
---sr

Shawn Rasheed

unread,
Feb 21, 2015, 3:02:07 PM2/21/15
to clo...@googlegroups.com
Using Lein 2's REPL, Ctrl-C doesn't cancel the REPL itself.

--
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
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
---sr

Erik Price

unread,
Feb 23, 2015, 6:30:11 PM2/23/15
to clo...@googlegroups.com

Vim Fireplace supports Ctrl-c without killing its REPL host. Highly recommended if you are a Vim user.

e

Reply all
Reply to author
Forward
0 new messages