Re: catch and throw, was Is multi-level function return possible?

rpw3@rpw3.org (Rob Warnock)
27 Mar 2014 04:23:12 GMT

          From comp.compilers

Related articles
Is multi-level function return possible? noitalmost@cox.net (noitalmost) (2014-03-10)
Re: Is multi-level function return possible? gneuner2@comcast.net (George Neuner) (2014-03-11)
Re: Is multi-level function return possible? federation2005@netzero.com (2014-03-26)
Re: catch and throw, was Is multi-level function return possible? rpw3@rpw3.org (2014-03-27)
Re: catch and throw, was Is multi-level function return possible? kaz@kylheku.com (Kaz Kylheku) (2014-03-27)
Re: catch and throw, was Is multi-level function return possible? usenet@bitblocks.com (Bakul Shah) (2014-03-26)
Re: catch and throw, was Is multi-level function return possible? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-03-27)
Re: exception catching in PL/I robin51@dodo.com.au (Robin Vowels) (2014-03-28)
Re: catch and throw, was Is multi-level function return possible? gneuner2@comcast.net (George Neuner) (2014-03-28)
Re: catch and throw, was Is multi-level function return possible? acolvin@efunct.com (mac) (2014-03-28)
[10 later articles]
| List of all articles for this month |

From: rpw3@rpw3.org (Rob Warnock)
Newsgroups: comp.compilers
Date: 27 Mar 2014 04:23:12 GMT
Organization: Rob Warnock, Consulting Systems Architect
References: 14-03-020 14-03-023 14-03-065
Keywords: errors, Lisp, history, comment
Posted-Date: 27 Mar 2014 00:45:11 EDT
Originator: rpw3@rpw3.org (Rob Warnock)

<federation2005@netzero.com> 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 <rpw3@rpw3.org>
627 26th Avenue <http://rpw3.org/>
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]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.