lispEn 2022-11-17 18:13:33

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 puede interesar
lisp codeEn 2022-07-13 13:12:00