 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Steven T. Hatton Guest
|
Posted: Thu Oct 28, 2004 1:43 am Post subject: The history of throw? |
|
|
I just read the section in _The_GNU_Emacs_Lisp_Reference_Manual_
on /Explicit/ /Nonlocal/ /Exits/[*] and had to wonder what language first
introduced the idea of throwing, catching, and unwinding. Note that
(Emacs) Lisp does not have something called 'exception', nor does it have a
'try' keyword. So what we find in C++ is certainly not taken from Lisp
without modification if indeed it was influenced by Lisp at all. I've read
that the concept of 'stack unwinding' was borrowed from Lisp. Does anybody
know the details of this history?
http://www.gnu.org/software/emacs/elisp-manual/html_node/elisp_130.html#SEC130
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell
|
|
| Back to top |
|
 |
E. Robert Tisdale Guest
|
Posted: Thu Oct 28, 2004 2:07 am Post subject: Off Topic: The history of throw? |
|
|
Steven T. Hatton wrote:
| Quote: |
What language first introduced the idea of throwing, catching, and unwinding.
|
Fortran.
"The alternate RETURN allows a procedure to return
to one of the several labelled statenebts in the calling program unit
dependent upon the value of an integer variable."
|
|
| Back to top |
|
 |
E. Robert Tisdale Guest
|
Posted: Thu Oct 28, 2004 2:09 am Post subject: Re: Off Topic: The history of throw? |
|
|
E. Robert Tisdale wrote:
| Quote: | Steven T. Hatton wrote:
What language first introduced the idea of throwing, catching, and
unwinding.
Fortran.
"The alternate RETURN allows a procedure to return
to one of the several labelled statenebts in the calling program unit
to one of the several labelled statements in the calling program unit
dependent upon the value of an integer variable."
|
|
|
| Back to top |
|
 |
Andrew Koenig Guest
|
Posted: Thu Oct 28, 2004 2:41 am Post subject: Re: The history of throw? |
|
|
"Steven T. Hatton" <susudata (AT) setidava (DOT) kushan.aa> wrote
| Quote: | I just read the section in _The_GNU_Emacs_Lisp_Reference_Manual_
on /Explicit/ /Nonlocal/ /Exits/[*] and had to wonder what language first
introduced the idea of throwing, catching, and unwinding.
|
Probably PL/I, in approximately 1968.
|
|
| Back to top |
|
 |
osmium Guest
|
Posted: Thu Oct 28, 2004 3:07 am Post subject: Re: The history of throw? |
|
|
"Andrew Koenig" writes:
| Quote: | I just read the section in _The_GNU_Emacs_Lisp_Reference_Manual_
on /Explicit/ /Nonlocal/ /Exits/[*] and had to wonder what language first
introduced the idea of throwing, catching, and unwinding.
Probably PL/I, in approximately 1968.
|
Just a guess, but my guess is PL/I also.
|
|
| Back to top |
|
 |
Steven T. Hatton Guest
|
Posted: Thu Oct 28, 2004 3:31 am Post subject: RE: The history of throw? |
|
|
E. Robert Tisdale wrote:
| Quote: | Steven T. Hatton wrote:
What language first introduced the idea of throwing, catching, and
unwinding.
Fortran.
"The alternate RETURN allows a procedure to return
to one of the several labelled statenebts in the calling program unit
dependent upon the value of an integer variable."
As regards C++, which was the overall topic of my post, I must say there are |
many aspects of Lisp error handling combined with catch and throw that seem
to clearly indicate a common origin. Even the concept of RAII seems to be
present. There are differences, but I am specifically interested in what
influences contributed to C++'s exception handling mechanism. Here is a
list of similarities I've noticed between Lisp and C++ regarding C++'s
exception handling.
The use of catch and throw. Note that in Lisp these are not intended
primarily for error handling, but they have clear similarities with the
error handling mechanism.
The use of error symbols is very similar to the use of exceptions in C++.
* Error symbols are arranged in a hirearchie with 'error' at the root. This
is analogous to the derivation hirearchie in the Standard Library.
* Error symbols carry with them a string intended for printing human
readable messages. This is analogous to the string returned by
std::exception::what() in C++
* Error symbols are passed up the call stack to until they encounter a
handler that accepts their type. Clearly analogous to the C++ mechanism of
using multiple catch() statements.
* If no handler is encountered, the process is terminated.
As the forms are exited, all local variable are unbound.
Though technically more similar to Java's finally than C++'s destructor, the
'unwind-project' 'cleanup-forms' serve an analogous purpose. To use C++
terminology, they ensure the essential invariants are preserved: " The
unwind-protect construct is essential whenever you temporarily put a data
structure in an inconsistent state; it permits you to make the data
consistent again in the event of an error or throw."
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell
|
|
| Back to top |
|
 |
Richard Herring Guest
|
Posted: Thu Oct 28, 2004 11:35 am Post subject: Re: Off Topic: The history of throw? |
|
|
In message <clpk6f$9lg$1 (AT) nntp1 (DOT) jpl.nasa.gov>, E. Robert Tisdale
<E.Robert.Tisdale (AT) jpl (DOT) nasa.gov> writes
| Quote: | Steven T. Hatton wrote:
What language first introduced the idea of throwing, catching, and
unwinding.
Fortran.
"The alternate RETURN allows a procedure to return
to one of the several labelled statenebts in the calling program unit
dependent upon the value of an integer variable."
|
That's just syntactic sugar for writing "if (<hidden return value>) goto
<a label elsewhere in this function>;" immediately after the function
call. There's no equivalent of unwinding the call stack or catching.
--
Richard Herring
|
|
| Back to top |
|
 |
E. Robert Tisdale Guest
|
Posted: Thu Oct 28, 2004 5:55 pm Post subject: Re: Off Topic: The history of throw? |
|
|
Richard Herring wrote:
| Quote: | E. Robert Tisdale writes:
Steven T. Hatton wrote:
What language first introduced the idea of throwing, catching, and
unwinding.
Fortran.
"The alternate RETURN allows a procedure to return
to one of the several labelled statements in the calling program unit
dependent upon the value of an integer variable."
That's just syntactic sugar for writing
"if (<hidden return value>) goto <a label elsewhere in this function>;"
immediately after the function call.
There's no equivalent of unwinding the call stack or catching.
|
Neither Fortran or C++ specify a stack much less stack unwinding.
The point is that the notion of exception handling appears
in the earliest high level computer programming languages.
|
|
| Back to top |
|
 |
osmium Guest
|
Posted: Thu Oct 28, 2004 6:13 pm Post subject: Re: Off Topic: The history of throw? |
|
|
"E. Robert Tisdale" writes:
| Quote: | The point is that the notion of exception handling appears
in the earliest high level computer programming languages.
|
Tell us what facilities for handling exceptions were provided in Fortran II.
|
|
| Back to top |
|
 |
Ron Natalie Guest
|
Posted: Thu Oct 28, 2004 6:33 pm Post subject: Re: Off Topic: The history of throw? |
|
|
E. Robert Tisdale wrote:
| Quote: |
Neither Fortran or C++ specify a stack much less stack unwinding.
The point is that the notion of exception handling appears
in the earliest high level computer programming languages.
|
Actually, while C++ doesn't define the stack (at least not in
the concept of using it for subroutine linkage), it does use
the term "stack unwinding" in the description of getting from
the point of throw to the catch, destroying local variables
along the way.
|
|
| Back to top |
|
 |
Dave Vandervies Guest
|
Posted: Thu Oct 28, 2004 8:01 pm Post subject: Re: Off Topic: The history of throw? |
|
|
In article <4181396e$0$28230$9a6e19ea (AT) news (DOT) newshosting.com>,
Ron Natalie <ron (AT) sensor (DOT) com> wrote:
| Quote: | E. Robert Tisdale wrote:
Neither Fortran or C++ specify a stack much less stack unwinding.
The point is that the notion of exception handling appears
in the earliest high level computer programming languages.
Actually, while C++ doesn't define the stack (at least not in
the concept of using it for subroutine linkage),
|
It does define a subroutine call mechanism that's required to look,
feel, and smell like a stack, though.
| Quote: | it does use
the term "stack unwinding" in the description of getting from
the point of throw to the catch, destroying local variables
along the way.
|
Wouldn't it be the (abstract) function-invocation stack that this refers
to, and not necessarily something like the hardware-supported stack that
most general-purpose processors use to implement such a thing?
dave
--
Dave Vandervies [email]dj3vande (AT) csclub (DOT) uwaterloo.ca[/email]
The perfect tool when you want output in a rigid column format at the
possible expense of the data integrity.
--Kaz Kylheku in comp.lang.c
|
|
| Back to top |
|
 |
Richard Herring Guest
|
Posted: Fri Oct 29, 2004 9:04 am Post subject: Re: Off Topic: The history of throw? |
|
|
In message <clrbng$7uq$1 (AT) nntp1 (DOT) jpl.nasa.gov>, E. Robert Tisdale
<E.Robert.Tisdale (AT) jpl (DOT) nasa.gov> writes
| Quote: | Richard Herring wrote:
E. Robert Tisdale writes:
Steven T. Hatton wrote:
What language first introduced the idea of throwing, catching, and
unwinding.
Fortran.
"The alternate RETURN allows a procedure to return
to one of the several labelled statements in the calling program unit
dependent upon the value of an integer variable."
That's just syntactic sugar for writing
"if (<hidden return value>) goto <a label elsewhere in this function>;"
immediately after the function call.
There's no equivalent of unwinding the call stack or catching.
Neither Fortran or C++ specify a stack much less stack unwinding.
|
The words "stack" and "unwinding" may not be used, but C++ provides for
(a) transferring control *an unspecified number of layers layer out* in
a sequence of nested function calls, (b) cleaning up everything which
goes out of scope as a result of this.
Fortran doesn't.
| Quote: | The point is that the notion of exception handling appears
in the earliest high level computer programming languages.
|
Possibly, but you haven't demonstrated it.
--
Richard Herring
|
|
| Back to top |
|
 |
Jerry Coffin Guest
|
Posted: Fri Oct 29, 2004 7:21 pm Post subject: Re: Off Topic: The history of throw? |
|
|
Richard Herring <junk@[127.0.0.1]> wrote
[ ... ]
| Quote: | The point is that the notion of exception handling appears
in the earliest high level computer programming languages.
Possibly, but you haven't demonstrated it.
|
FORTRAN didn't. PL/I would be the next obvious choice -- it not only
had exception handling, but more or less forced its use on a regular
basis, because it used it for quite a few situations that really
weren't exceptional. One obvious example was reading a file, with the
end of the file being signaled by an exception.
It's certainly true that PL/I's exception handling was (both
syntactically and semantically) substantially different from C++'s,
but I think almost anybody who studied the two would agree that the
similarities are sufficient to say it really WAS exception handling as
the term is normally used.
--
Later,
Jerry.
The universe is a figment of its own imagination.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|