lispEn 2022-11-17 18:13:33
228

Condition Handler

One of Lisp's great features is its condition system. It serves a similar purpose to the exception handling systems in Java, Python, and C++ but is more flexible. In fact, its flexibility extends beyond error handling conditions are more general than exceptions in that a condition can represent any occurrence during a program's execution that may be of interest to code at different levels on the call stack. (1)


1) https://gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html


The macro HANDLER-CASE establishes this kind of condition handler.


 The basic form of a HANDLER-CASE is as follows:

 (handler-case expression

   error-clause*)


where each error-clause is of the following form:

 (condition-type ([var]) code)


Example:

https://gist.github.com/juan-reynoso/a10d5b6e885c6aa2c7fdfd43561c79cf



Condition Handler in action



#lisp #handler-case #conditions


También te podría interesar
lisp codeEn 2022-07-13 13:12:00
lispEn 2019-09-17 20:18:42
lispEn 2022-11-01 13:51:41
Common lisp is great because of who it is designed by...
lispmxEn 2017-12-26 12:17:40
lispEn 2022-12-06 15:05:07
In this post we will show the Common Lisp version and implementation you're using, from the REPL.