The less-familiar parts of Lisp for beginners — muffle-warning

Continuing onward, we arrive at muffle-warning.  This might not seem like a particularly interesting or subtle function, but its behaviour is a bit different from what a newcomer from C++ might expect.

To begin with, you should probably review the articles on exception handling in Lisp.

While we haven’t discussed the warn function yet, we’ll go over it a bit here.  This function generates a Lisp condition (think exception).  Recall that Lisp conditions, if not caught, need not lead to termination.  If a condition is signaled with error, and there is no handler for it, the execution will enter the debugger.  If, instead, signal is used, then an uncaught condition causes execution to continue as if signal had not been invoked.  The warn function is similar to signal, but when it falls through unhandled, or returns from a restart, it prints a diagnostic text on the error stream.  That is, an unhandled warning doesn’t behave as if it had not been invoked at all, but instead produces some diagnostic in an implementation-defined manner.

So, what does muffle-warning do?  It is a function that can be invoked only inside a restart for a warning condition while such a condition is active.  The muffle-warning function suppresses the output from the warning before allowing execution to proceed after the warn invocation.  After the restart exits, execution continues after the warn, but with the normal error stream output suppressed for that one invocation.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

反垃圾邮件 / Anti-spam question * Time limit is exhausted. Please reload CAPTCHA.