Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!glacier!hplabs!hpfcdc!hpfcla!hpfcmt!chan From: chan@hpfcmt Newsgroups: net.lang Subject: Re: and if you put this in your language ... Message-ID: <9100003@hpfcmt> Date: Mon, 14-Apr-86 13:29:00 EST Article-I.D.: hpfcmt.9100003 Posted: Mon Apr 14 13:29:00 1986 Date-Received: Fri, 18-Apr-86 09:05:23 EST References: <1187@mmintl> Lines: 47 > How do I tell one CATCH from another? Is (CATCH ...) an expression > that returns a value in other expressions? If so, what does it return > if nothing is thrown to it? The tag is the only thing that distinguishes catchers. Remember though, that a particular CATCH can only be thrown to while its forms are being evaluated. If no THROW occurs, the CATCH returns whatever its last form returned. If a THROW does occur, the CATCH returns the value specified in the THROW. > The (UNWIND-PROTECT ...) looks like a > demon, i.e. it executes whenever there is an exit from the protected > form as an interjection. Also, what happens when there is a THROW? > Does flow control transfer to the CATCH or does it continue? I'm fuzzy as to what you mean here, but I'll try to explain with an example. (catch 'foo (unwind-protect (if (= x 1) (throw 'foo "equal")) ;; Protect forms (print "Cleaning up...") ) "unequal" ) If x is 1, then this form returns "equal" after printing "Cleaning up...". This is the case where the catch returns what it is thrown. Note that the protect form(s) are evaluated, but the second
of the catch ("unequal") is thrown over and does not get evaluated. If x is not 1, then this form returns "unequal" after printing "Cleaning up...". This is the case where the catch returns whatever the last returns. > These may seem like dumb questions, but if one is not a LISP programmer > it seems a little obscure. They don't seem dumb to me, thanks for showing some interest. My original posting was kept intentionally short and cryptic. -- Chan Benson {ihnp4 | hplabs}!hpfcla!chan Hewlett-Packard Company Fort Collins, CO As usual, HP has nothing to do with what I say here.