From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!tudelft.nl!transit0.news.tiscali.nl!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscali.nl!not-for-mail Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Class hierarchy of exceptions (Ada, C++) References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <1111607633.301232.62490@z14g2000cwz.googlegroups.com> <87oed6wvyx.fsf_-_@insalien.org> <1111876424.201726@athnrd02> From: Ludovic Brenta Date: Mon, 28 Mar 2005 12:49:57 +0200 Message-ID: <874qewvycq.fsf@insalien.org> User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:dZhgw7F9dLmXWd85NwYTF8zfIh4= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tiscali bv NNTP-Posting-Date: 28 Mar 2005 12:50:03 CEST NNTP-Posting-Host: 83.134.239.98 X-Trace: 1112007003 dreader2.news.tiscali.nl 44070 83.134.239.98:36148 X-Complaints-To: abuse@tiscali.nl Xref: g2news1.google.com comp.lang.ada:10065 comp.lang.c++:47579 comp.realtime:1770 comp.software-eng:5402 Date: 2005-03-28T12:50:03+02:00 List-Id: Ioannis Vranos writes: > Ludovic Brenta wrote: > >> I kind of like Ada exceptions as they are now. Because one cannot >> carry much information in them (apart from the kluge you >> mentioned), one tends not to rely on them for the normal flow of >> operations. I have seen Java programs that would rely on >> exceptions for all kinds of things, leading to spaghetti code. In >> C++ I find it a bit odd that I can throw and catch an entire hash >> table as an exception if I want to. > > > Being able to do whatever you want can certainly cause confusion for > anyone who is used to be helped how to program. > > However, if you know the language, you know what to do and what to > not do. Also this way is more powerful. Ah, that same old argument again. I don't know about you; you may be the Perfect Programmer Who Knows What They're Doing, in which case I don't know excactly why you are even condescending to read mere mortals' babbling. As for me, I have been programming in 10 languages or so for 15 years, and I still appreciate all the help I can get. In fact, the more experience I get, the more I appreciate it. But my point was not just about being helped; it was also about the mathematical purity of the concept of exceptions. If an exception can be anything at all, then what is so exceptional about it? I'm not entirely decided on this point (being a mere engineer and not a mathematician), I'm just uneasy at the thought, and I remember badly-written programs I've seen before. Pascal Obry once made an interesting remark: what is important for the safety of a language is not what it allows but what it forbids. >> The C++ way of catching all exceptions of a class and its derived >> classes can lead to confusion. One can have multiple exception >> handlers for the same exception and it may not be immediately >> obvious to the reader which one is called. I see this as a >> maintenance problem. > > > :-) Being able to walk alone can also lead to confusion. Isn't it > better if you walk with assistance? Ah but *I* am the one assisting people, not to walk but to fly aircraft. To some extent, they depend on me for their lives, and I take that seriously. So, yes, as a program maintainer, I appreciate any and all help, assurance and guarantees I can get. A C++ program that throws a Window or a Button object or a Database_Connection object violates the Law of Least Astonishment. If I read C++ code, I must be prepared to see such things happen, and be astonished. If I read Ada code, I know that this cannot happen, so I can move on to more interesting considerations. >> Another concern of mine with exception classes is that they'd have >> to be allocated on the heap. > > > No, they do not have to. One can (and in most times does) throw an > exception object on the stack. Please explain. I am not a compiler writer, and I fail to understand how the compiler can allocate on the stack, and then propagate the exception up the stack. -- Ludovic Brenta.