4

I've been messing around with developing a game in clojure, and one thing I've been really excited about is hot swapping in code.

I've been using swank clojure and emacs with the lein-swank plugin.

My main problem has been that of typos. Say I update a function, make a small error, and then hit Ctrl-C Ctrl-C to send it off to the REPL:

(if (> (rand) .5) (println "yay") (println "boo"))

(I should have written 0.5, not .5.)

In that case, the entire program will simply crash and burn, and I'll need to restart the whole thing. Hot swapping is great, but if I can't make even a tiny error then what's the point?

So what exactly is the workflow here? Am I missing something? Or is there a way to make swank clojure more resilient to these little errors? (I imagine that the best thing would simply be to reset to a previous working state, although that may be a little difficult.)

Thanks!

thedayturns
  • 9,723
  • 5
  • 33
  • 41

2 Answers2

2

The program shouldn't “crash and burn”—it should raise an exception and throw you into the debugger, which you can dismiss by hitting Q (sldb-quit). After dismissing the debugger, the program is supposed to continue running normally. If this is not what happens, your SLIME configuration is probably broken somehow.

Matthias Benkard
  • 15,497
  • 4
  • 39
  • 47
0

Personally I recommend C-M-x over C-c C-c. I don't think either one should have the problem you're experiencing, though, so switching may not fix it.

amalloy
  • 89,153
  • 8
  • 140
  • 205
  • Really? What happens when you accidentally C-M-x some code that accesses a property of nil or something? Would that imply that my setup is messed up somehow? – thedayturns May 05 '12 at 23:47
  • 1
    \*shrug\* Slime opens up a window with a stacktrace. I look through it if there's anything interesting, and then press Q to dismiss it and get back to work. – amalloy May 07 '12 at 01:04