Re: We do not use C++ exceptions
On Mar 15, 10:49 am, Damien Kick <dk...@earthlink.net> wrote:
I was interested to read in _The Design and Evolution of C++_ that
introducing resumption semantics to C++ exceptions had been considered
for C++ but that the proposal had been rejected. IIRC, Stroustrup had
solicited feedback from systems with existing implementations of
resumption semantics and that all of the users to whom he had spoken had
found that any of their use of resumption had eventually been replaced
by other mechanisms. Again, IIRC, he had mentioned Mesa [1] which,
according to Wikipedia, was developed in the late 70s. Common Lisp was
ratified as an ANSI standard , including the condition system, in 1994.
I'm not sure, however, when work first began on the CL condition
system nor if any previous Lisp implementation made use of them. I'm
assuming that there was little if no overlap in the Mesa team and the CL
standards committee. I would guess that many, if not most or even all,
of CL users would disagree with Stroustrup's conclusion regarding
resumption semantics not being particularly useful as they were
incorporated into CL.
There is a big difference between resumption semantics as they were
suggested for C++ and restarts as CL has them. The proposed resumption
semantics were Windows SEH-like: execution restarts at or directly
after the instruction that threw. This is really a very limited form
of resumption.
Common Lisp has a far more powerful and complex system of restarts.
Translated to pseudo-C++, it would look something like this:
try {
leFunction();
} catch(signal s) {
if (s == something)
restart rs1;
else if(s == other)
restart rs2;
}
void leFunction()
{
restart(rs1) {
// some code executed if restarted from here
} do {
// code executed in normal flow, and after restart
lautreFunction();
}
// the restart rs1 is no longer active here
}
void lautreFunction() {
restart(rs2) {
} do {
signal something; // enters the catch, then restarts from rs1
}
}
Sebastian
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]