Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news.misty.com!news.iecc.com!.POSTED!nerds-end From: rpw3@rpw3.org (Rob Warnock) Newsgroups: comp.compilers Subject: Re: catch and throw, was Is multi-level function return possible? Date: 27 Mar 2014 04:23:12 GMT Organization: Rob Warnock, Consulting Systems Architect Lines: 62 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-03-068@comp.compilers> References: <14-03-020@comp.compilers> <14-03-023@comp.compilers> <14-03-065@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: miucha.iecc.com 1395895512 45788 2001:470:1f07:1126:0:676f:7373:6970 (27 Mar 2014 04:45:12 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Thu, 27 Mar 2014 04:45:12 +0000 (UTC) Keywords: errors, Lisp, history, comment Posted-Date: 27 Mar 2014 00:45:11 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Originator: rpw3@rpw3.org (Rob Warnock) Xref: csiph.com comp.compilers:1190 wrote: +--------------- | George Neuner wrote: | > The modern term is "exception". See also "non-local" control | > transfer, exit and/or return, and "escape" or "backtracking" | > continuation. | | Right, the contemporary (not "modern") notion is the catch-throw | paradigm. I like to think of it as the "cap and trap" mechanism. | | I believe it originates with Prolog in the 1970's, since (a) catch | and throw are part of Prolog's library of built-in functions, and | (b) the multi-level breakout has always been an integral part of | its run-time system. +--------------- According to Gabriel and Steele in "The Evolution of Lisp"[1], Lisp 1.5 [early 1960s] had (ERRSET form), which: ...evaluates *form* in a context in which errors do not terminate the program or enter the debugger. If *form* does not cause an error, ERRSET returns a singleton list of the value. If execution of *form* does cause an error, the ERRSET form quietly returns NIL. MacLisp [late 1960s] added the function ERR, which signals an error. If ERR is invoked within the dynamic context of an ERRSET form, then the argument to ERR is returned as the value of the ERRSET form. Programmers soon began to use ERRSET and ERR not to trap and signal errors but for more general control purposes (dynamic non-local exits). Unfortunately, this use of ERRSET also quietly trapped unexpected errors, making programs harder to debug. A new pair of primitives, CATCH and THROW, was introduced into MacLisp in June 1972 so that ERRSET could be reserved for its intended use of error trapping So unless Prolog's implementation predates June 1972, I would suggest that Lisp has priority on CATCH/THROW. -Rob [1] http://www.dreamsongs.com/Files/Hopl2.pdf The Evolution of Lisp Guy L. Steele Jr. & Richard P. Gabriel [Presented at the ACM/SIGPLAN Second History of Programming Languages Conference, April 1993] [2] http://www.dreamsongs.com/Files/HOPL2-Uncut.pdf [Uncut version, contains ~32 pages of material trimmed from conference version.] ----- Rob Warnock 627 26th Avenue San Mateo, CA 94403 [I happen to have a copy of the LISP 1.5 Programmer's Manual, second edition, in my hand, and while it says nothing about ERRSET, on page 35 it does describe a form called errorset[] that evaluates an expression and returns a list of the expression's value if it worked, or nil if there was an error. Page 32 alludes to an error[] form that causes an error. Sure sounds like catch and throw to me, give or take the problem that it also catches and ignores real errors. The book was published in 1965. -John]