4 ms·
> With traditional exceptions, the stack unwind all the way to the "catch" block which has full responsibility of handling the exception. With CL conditions, yo
by phoe-krk 6y ago
> 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.
- Akronymus 6y agoIs this a consequence of the "mythical" treating code as data that lisp is often praised for?
- phoe-krk 6y agoNot 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.
- Akronymus 6y agoThanks 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.
- phoe-krk 6y agoUsing 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.
- Akronymus 6y agoForeign 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.