Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Lisp REPLs take that a step further, as you interact with and in your whole actually running program

With python, I can add a signal callback which calls the inbuilt breakpoint() function. This means I can send my application a given signal, let's say SIGTERM, and it'll drop into they python debugger whereby I can then drop further into the python REPL.

Does Lisp provide more than that out of interest?

Edit: ah I see hot reloading is a thing. Not explored that in python.



Many early Common Lisp systems had impressive error handling. Certain exceptions would automatically break to an interactive Lisp window.

But Common Lisp also has a fancy system for recovering from exceptions. So after you replaced the broken function, you'd often see a list of "restart" points from where you could retry a failed operation.

So even if you failed in the middle of a complex operation, you could test out a fix without needing to abandon the entire operation in progress.

I'm not entirely certain if this was as useful as it sounds, in practice, but it was certainly very impressive.


There was a book published just last year about the CL condition system for anyone who wants to better understand it (disclaimer: it's sitting on my desk but I haven't read it yet): https://link.springer.com/book/10.1007/978-1-4842-6134-7


It's like CSI vs Dr House. Debugging in python is forensic; you can figure out why your program died, but you can't really fix it. In common lisp, debugging can be curative as well as forensic. If you hit a problem like you call foo from bar, but foo isn't defined you can just write an implementation in your editor, send it to the running lisp and continue with the current execution. If a class is missing something, you can change the definition and not onl y have it take effect for all live instances, but you can also say how to transform the existing instances in your program. Have a look at the example given in the "docs": http://clhs.lisp.se/Body/f_upda_1.htm; you should get the gist even without knowing lisp.

I'm overgeneralizing (I've had remote repls in production python application and used them to hotfix things), but only a little. You will appreciate the difference if you work with long running computations, where you don't want to have to start over from scratch if something went wrong right at the end.


Yes, it was mentioned in the post: you normally get prompted not just when there's a breakpoint, but when your code calls something that doesn't yet exist, for example, or try to access a non-defined variable [1]... you have the option to "fix" the issue and continue from the same point, continue with a different value, or just let it crash... and there's stuff like profiling and de-compiling [2] which are all available directly from the REPL as well.

[1] https://lispcookbook.github.io/cl-cookbook/debugging.html

[2] https://lispcookbook.github.io/cl-cookbook/performance.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: