From 1092058029589897301
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1014db,2b472f0bbf95bd3e,start
X-Google-Attributes: gid1014db,public
X-Google-Thread: f78e5,2b472f0bbf95bd3e,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2000-10-30 10:44:03 PST
Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!europa.netcrusader.net!194.159.255.21!dispose.news.demon.net!demon!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: Anatoli Tubman <anatoli@my-deja.com>
Newsgroups: comp.lang.c,.moderated,comp.std.c++
Subject: Throwing from destructors, again.
Date: Mon, 30 Oct 2000 18:43:14 GMT
Organization: Deja.com - Before you buy.
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <8suiva$qkm$1@nnrp1.deja.com>
X-Trace: mail2news.demon.co.uk 972931405 mail2news:6896 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Article-Creation-Date: Sun Oct 22 11:27:40 2000 GMT
X-Http-User-Agent: Mozilla/4.75 [en] (X11; U; SunOS 5.6 sun4u)
X-Http-Proxy: 1.0 x68.deja.com:80 (Squid/1.1.22) for client 12.11.149.5
X-MyDeja-Info: XMYDJUIDanatoli
Lines: 70
Xref: supernews.google.com comp.lang.c:18664 comp.std.c++:1710

 What about changing the language in such a way that multiple
exceptions are allowed to coexist? Throwing from destructors would
mean "add new exception to the currently running exception set and
continue unwinding" which is safe.  My proposal is very informal at
this stage.

When an exception escapes a destructor as a result of stack
unwinding, we (instead of calling terminate ()) just add
the offending exception to the current exception set.
Semantics of try/catch becomes a bit more complicated.
As we have multiple active exceptions now, more than one
catch clause of a given block can be executed. Throw from
within a catch() does not take effect immediately but only
after all exceptions from the current list are handled.

Here's the algorithm of new try/catch:

         try { something(); }
           catch (A)   { }
           catch (B)   { }
           catch (...) { }

becomes:

         try { something(); }
         catch (...) {
           new_e_list = empty_list;
           for each e in old_e_list {
             try {
               try { throw e }
                 catch (A)   { } // old sequence
                 catch (B)   { } // of catch blocks
                 catch (...) { } // goes here, unchanged
             }
             catch (...) {
               insert caught exception in new_e_list
             }
           }
           if new_e_list is not empty
             resume unwinding with new_e_list
         }

The proposal is less radical than it seems, because meaning of old
programs is not changed. Well, old programs that terminate() because of
a double exception don't anymore, but even this can be cured: in case of
double exception, call the function double_exception(). The default
value of double_exception() is terminate(). Call to
       set_double_exception (handle_double_exceptions)
swithes to the described behaviour. Call to
       set_double_exception (terminate)
reverts to old behaviour.

Am I totally off here? Was such thing ever considered?


--
Regards
Anatoli (anatoli<at>ptc<dot>com) opinions aren't


Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]



