Question for the etymology wizards out there: which programming language was the first to use the try/catch/finally syntax found in today's Java/.NET languages?
I believe it was C++ and I think Java/C# added finally for resource cleanup (finally is not in C++). Unfortunately I have no references... yet.
Neat page of all the exception syntax: http://en.wikipedia.org/wiki/Exception_handling_syntax
I believe it is C++. If its not then Stroustrup needs to give credit. In his paper: http://www.research.att.com/~bs/except.pdf He does not mention any influences and does not reference any other material other than his own.
Posted on Twitter by Mike Fikes, shared with me by Paweł Kapała:
MacLisp added the function
ERR
, which signals an error. IfERR
is invoked within the dynamic context of anERRSET
form, then the argument toERR
is returned as the value of theERRSET
form.Programmers soon began to use
ERRSET
andERR
not to trap and signal errors but for more general control purposes (dynamic non-local exits). Unfortunately, this use ofERRSET
also quietly trapped unexpected errors, making programs harder to debug. A new pair of primitives,CATCH
andTHROW
, was introduced into MacLisp in June 1972 [emphasis mine] so thatERRSET
could be reserved for its intended use of error trapping.The lesson of
ERRSET
andCATCH
is important. The designers ofERRSET
and laterERR
had in mind a particular situation and defined a pair of primitives to address that situation. But because these facilities provided a combination of useful and powerful capabilities (error trapping plus dynamic non-local exits), programmers began to use these facilities in unintended ways. Then the designers had to go back and split the desired into pieces with alternative interfaces. This pattern of careful design, unintended use, and later redesign is common in the evolution of Lisp.
— from “The Evolution of Lisp,” by Guy Steele and Richard Gabriel
Source: https://twitter.com/mfikes/status/881943130588753920
<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">“The Evolution of Lisp,” by Guy Steele and Richard Gabriel</p>— Mike Fikes (@mfikes) <a href="https://twitter.com/mfikes/status/881950560508940288">July 3, 2017</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
Common Lisp predates C++ by a long time, and was based earlier Lisps. Java was, of course, created by Lisp men who were very aware of this. But Java is Lisp polluted by C, so they also added the checked exception specification nonsense.
Common Lisp went further and actually enabled the catch to interact with the throw routine, including to tell the throw to continue. The stack was simply not unwound until the catch was done. That meant you could throw warnings like low memory as well as throwing fails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With