The less-familiar parts of Lisp for beginners — throw

I’m going to talk a bit now about catch and throw.  These aren’t really obscure, particularly to somebody coming from a C++ background, who probably goes looking for these keywords when wanting to find out about throwing exceptions.  I talked at length about exceptions in Lisp earlier, and skipped over these, as they’re not really interesting or novel, but they deserve a mention.

So, catch and throw.  Similar in concept to the operations in C++, but rather than the catch specializing on objects, catch specifies a label, and throw jumps to the named label.  Consequently, you don’t have cascading catch directives, as you might have in C++.  If there is no matching catch for the throw, an error is signaled.

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.