News for hackers. Stuff that matters.
Re:The Common Lisp Condition System – Upcoming Book by kqr on Wednesday July 15, 2020 @09:07AM (#23844622)
Something else that sets it apart is that the decision on how to handle something is decoupled from the implementation of that thing.

With traditional exceptions, the stack unwind all the way to the "catch" block which has full responsibility of handling the exception. With CL conditions, you can implement multiple handlers which do not catch the exception, and then a handler way up in the stack can decide which of the low-level handlers to run.

It sounds bonkers, but when you've tried it you'll see that "normal" exceptions are a very crippled version of it.

Re:The Common Lisp Condition System – Upcoming Book by phoe-krk on Wednesday July 15, 2020 @09:11AM (#23844670)
> With traditional exceptions, the stack unwind all the way to the "catch" block which has full responsibility of handling the exception. With CL conditions, you can implement multiple handlers which do not catch the exception, and then a handler way up in the stack can decide which of the low-level handlers to run.

I'd say that this is the main difference that sets the CL condition system apart from mainstream programming languages. In these other languages, when an error happens, the stack is automatically unwound; in Lisp, when an error happens, the stack is automatically wound further, and the code executed in such way has the full choice of whether to unwind the stack and where exactly to unwind it to; this information is provided in the dynamic environment in which a given piece of code is running.

Re:The Common Lisp Condition System – Upcoming Book by Akronymus on Wednesday July 15, 2020 @11:07AM (#23846229)
Is this a consequence of the "mythical" treating code as data that lisp is often praised for?
Re:The Common Lisp Condition System – Upcoming Book by phoe-krk on Wednesday July 15, 2020 @11:13AM (#23846334)
Not at all. It is a consequence of language design of other languages.

When you divide by zero in Java, then there is nothing set in stone that prevents the language from winding the stack further and executing some code that will analyze the dynamic environment in which the error happened, calling all error handlers found in the dynamic environment, and only then - if no handler transferred control outside the error side - either entering an interactive debugger of some sorts or giving up and crashing.

But instead Java goes another way and immediately destroys the stack by throwing an exception. That's a design choice made by Java creators. Lisp's homoiconicity has nothing to do with this.

You can also analyze the Python implementation of the condition system posted elsewhere in the comments - that's an example of a condition system in a non-homoiconic language.

Re:The Common Lisp Condition System – Upcoming Book by Akronymus on Wednesday July 15, 2020 @11:24AM (#23846552)
Thanks for explaining that to me. It is all just so alien to me due to my experience so far. But I am really excited to learn it properly.
Re:The Common Lisp Condition System – Upcoming Book by phoe-krk on Wednesday July 15, 2020 @11:26AM (#23846603)
Using the word "alien" in context of a language often described as "made with alien technology" sounds peculiarly fitting.

The image-based Lisp is just very very different when compared to mainstream batch languages like C, Rust, or Java.

Re:The Common Lisp Condition System – Upcoming Book by Akronymus on Wednesday July 15, 2020 @12:13PM (#23847352)
Foreign implies a sort of familiarity/similarity to what you know. Hence me using alien as it is different enough, to basically be, well, alien.

But that only wants to make me learn it properly more.